1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import * as request from 'supertest'
6 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
8 buildAbsoluteFixturePath,
10 checkVideoFilesWereRemoved,
16 flushAndRunMultipleServers,
23 setAccessTokensToServers,
31 } from '../../../../shared/extra-utils'
32 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
35 addVideoCommentThread,
38 getVideoCommentThreads,
39 getVideoThreadComments
40 } from '../../../../shared/extra-utils/videos/video-comments'
41 import { VideoComment, VideoCommentThreadTree, VideoPrivacy } from '../../../../shared/models/videos'
43 const expect = chai.expect
45 describe('Test multiple servers', function () {
46 let servers: ServerInfo[] = []
49 let videoChannelId: number
51 before(async function () {
54 servers = await flushAndRunMultipleServers(3)
56 // Get the access tokens
57 await setAccessTokensToServers(servers)
60 const videoChannel = {
61 name: 'super_channel_name',
62 displayName: 'my channel',
63 description: 'super channel'
65 await servers[0].channelsCommand.create({ attributes: videoChannel })
66 const { data } = await servers[0].channelsCommand.list({ start: 0, count: 1 })
67 videoChannelId = data[0].id
70 // Server 1 and server 2 follow each other
71 await doubleFollow(servers[0], servers[1])
72 // Server 1 and server 3 follow each other
73 await doubleFollow(servers[0], servers[2])
74 // Server 2 and server 3 follow each other
75 await doubleFollow(servers[1], servers[2])
78 it('Should not have videos for all servers', async function () {
79 for (const server of servers) {
80 const res = await getVideosList(server.url)
81 const videos = res.body.data
82 expect(videos).to.be.an('array')
83 expect(videos.length).to.equal(0)
87 describe('Should upload the video and propagate on each server', function () {
88 it('Should upload the video on server 1 and propagate on each server', async function () {
91 const videoAttributes = {
92 name: 'my super name for server 1',
97 description: 'my super description for server 1',
98 support: 'my super support text for server 1',
99 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
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.port === servers[0].port
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',
120 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
123 host: 'localhost:' + servers[0].port
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({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: 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, HttpStatusCode.OK_200, 'resumable')
184 await waitJobs(servers)
186 // All servers should have this video
187 for (const server of servers) {
188 const isLocal = server.url === 'http://localhost:' + servers[1].port
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:' + servers[1].port
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:' + servers[2].port
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:' + servers[2].port
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:' + servers[2].port
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 await viewVideo(servers[2].url, localVideosServer3[0])
505 await viewVideo(servers[2].url, localVideosServer3[0])
506 await viewVideo(servers[2].url, localVideosServer3[1])
510 await viewVideo(servers[2].url, localVideosServer3[0])
511 await viewVideo(servers[2].url, localVideosServer3[0])
513 await waitJobs(servers)
515 // Wait the repeatable job
518 await waitJobs(servers)
520 for (const server of servers) {
521 const res = await getVideosList(server.url)
523 const videos = res.body.data
524 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
525 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
527 expect(video0.views).to.equal(3)
528 expect(video1.views).to.equal(1)
532 it('Should view multiple videos on each servers', async function () {
535 const tasks: Promise<any>[] = []
536 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
537 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
538 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
539 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
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, remoteVideosServer3[1]))
543 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
544 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
545 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
547 await Promise.all(tasks)
549 await waitJobs(servers)
551 // Wait the repeatable job
554 await waitJobs(servers)
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)
594 let baseVideos = null
595 for (const server of servers) {
596 const res = await getVideosList(server.url)
598 const videos = res.body.data
600 // Initialize base videos for future comparisons
601 if (baseVideos === null) {
606 for (const baseVideo of baseVideos) {
607 const sameVideo = videos.find(video => video.name === baseVideo.name)
608 expect(baseVideo.likes).to.equal(sameVideo.likes)
609 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
615 describe('Should manipulate these videos', function () {
616 it('Should update the video 3 by asking server 3', async function () {
620 name: 'my super video updated',
625 description: 'my super description updated',
626 support: 'my super support text updated',
627 tags: [ 'tag_up_1', 'tag_up_2' ],
628 thumbnailfile: 'thumbnail.jpg',
629 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
630 previewfile: 'preview.jpg'
633 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
635 await waitJobs(servers)
638 it('Should have the video 3 updated on each server', async function () {
641 for (const server of servers) {
642 const res = await getVideosList(server.url)
644 const videos = res.body.data
645 const videoUpdated = videos.find(video => video.name === 'my super video updated')
646 expect(!!videoUpdated).to.be.true
648 const isLocal = server.url === 'http://localhost:' + servers[2].port
649 const checkAttributes = {
650 name: 'my super video updated',
655 description: 'my super description updated',
656 support: 'my super support text updated',
657 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
660 host: 'localhost:' + servers[2].port
664 commentsEnabled: true,
665 downloadEnabled: true,
666 tags: [ 'tag_up_1', 'tag_up_2' ],
667 privacy: VideoPrivacy.PUBLIC,
669 displayName: 'Main root channel',
670 name: 'root_channel',
674 fixture: 'video_short3.webm',
681 thumbnailfile: 'thumbnail',
682 previewfile: 'preview'
684 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
688 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
691 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
692 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
694 await waitJobs(servers)
697 it('Should not have files of videos 3 and 3-2 on each server', async function () {
698 for (const server of servers) {
699 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber)
700 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber)
704 it('Should have videos 1 and 3 on each server', async function () {
705 for (const server of servers) {
706 const res = await getVideosList(server.url)
708 const videos = res.body.data
709 expect(videos).to.be.an('array')
710 expect(videos.length).to.equal(2)
711 expect(videos[0].name).not.to.equal(videos[1].name)
712 expect(videos[0].name).not.to.equal(toRemove[0].name)
713 expect(videos[1].name).not.to.equal(toRemove[0].name)
714 expect(videos[0].name).not.to.equal(toRemove[1].name)
715 expect(videos[1].name).not.to.equal(toRemove[1].name)
717 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
721 it('Should get the same video by UUID on each server', async function () {
723 for (const server of servers) {
724 const res = await getVideo(server.url, videoUUID)
726 const video = res.body
728 if (baseVideo === null) {
733 expect(baseVideo.name).to.equal(video.name)
734 expect(baseVideo.uuid).to.equal(video.uuid)
735 expect(baseVideo.category.id).to.equal(video.category.id)
736 expect(baseVideo.language.id).to.equal(video.language.id)
737 expect(baseVideo.licence.id).to.equal(video.licence.id)
738 expect(baseVideo.nsfw).to.equal(video.nsfw)
739 expect(baseVideo.account.name).to.equal(video.account.name)
740 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
741 expect(baseVideo.account.url).to.equal(video.account.url)
742 expect(baseVideo.account.host).to.equal(video.account.host)
743 expect(baseVideo.tags).to.deep.equal(video.tags)
747 it('Should get the preview from each server', async function () {
748 for (const server of servers) {
749 const res = await getVideo(server.url, videoUUID)
750 const video = res.body
752 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
757 describe('Should comment these videos', function () {
758 let childOfFirstChild: VideoCommentThreadTree
760 it('Should add comment (threads and replies)', async function () {
764 const text = 'my super first comment'
765 await addVideoCommentThread(servers[0].url, servers[0].accessToken, videoUUID, text)
769 const text = 'my super second comment'
770 await addVideoCommentThread(servers[2].url, servers[2].accessToken, videoUUID, text)
773 await waitJobs(servers)
776 const threadId = await findCommentId(servers[1].url, videoUUID, 'my super first comment')
778 const text = 'my super answer to thread 1'
779 await addVideoCommentReply(servers[1].url, servers[1].accessToken, videoUUID, threadId, text)
782 await waitJobs(servers)
785 const threadId = await findCommentId(servers[2].url, videoUUID, 'my super first comment')
787 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
788 const childCommentId = res2.body.children[0].comment.id
790 const text3 = 'my second answer to thread 1'
791 await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, threadId, text3)
793 const text2 = 'my super answer to answer of thread 1'
794 await addVideoCommentReply(servers[2].url, servers[2].accessToken, videoUUID, childCommentId, text2)
797 await waitJobs(servers)
800 it('Should have these threads', async function () {
801 for (const server of servers) {
802 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
804 expect(res.body.total).to.equal(2)
805 expect(res.body.data).to.be.an('array')
806 expect(res.body.data).to.have.lengthOf(2)
809 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
810 expect(comment).to.not.be.undefined
811 expect(comment.inReplyToCommentId).to.be.null
812 expect(comment.account.name).to.equal('root')
813 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
814 expect(comment.totalReplies).to.equal(3)
815 expect(dateIsValid(comment.createdAt as string)).to.be.true
816 expect(dateIsValid(comment.updatedAt as string)).to.be.true
820 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
821 expect(comment).to.not.be.undefined
822 expect(comment.inReplyToCommentId).to.be.null
823 expect(comment.account.name).to.equal('root')
824 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
825 expect(comment.totalReplies).to.equal(0)
826 expect(dateIsValid(comment.createdAt as string)).to.be.true
827 expect(dateIsValid(comment.updatedAt as string)).to.be.true
832 it('Should have these comments', async function () {
833 for (const server of servers) {
834 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
835 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
837 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
839 const tree: VideoCommentThreadTree = res2.body
840 expect(tree.comment.text).equal('my super first comment')
841 expect(tree.comment.account.name).equal('root')
842 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
843 expect(tree.children).to.have.lengthOf(2)
845 const firstChild = tree.children[0]
846 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
847 expect(firstChild.comment.account.name).equal('root')
848 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
849 expect(firstChild.children).to.have.lengthOf(1)
851 childOfFirstChild = firstChild.children[0]
852 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
853 expect(childOfFirstChild.comment.account.name).equal('root')
854 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
855 expect(childOfFirstChild.children).to.have.lengthOf(0)
857 const secondChild = tree.children[1]
858 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
859 expect(secondChild.comment.account.name).equal('root')
860 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
861 expect(secondChild.children).to.have.lengthOf(0)
865 it('Should delete a reply', async function () {
868 await deleteVideoComment(servers[2].url, servers[2].accessToken, videoUUID, childOfFirstChild.comment.id)
870 await waitJobs(servers)
873 it('Should have this comment marked as deleted', async function () {
874 for (const server of servers) {
875 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
876 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
878 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
880 const tree: VideoCommentThreadTree = res2.body
881 expect(tree.comment.text).equal('my super first comment')
883 const firstChild = tree.children[0]
884 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
885 expect(firstChild.children).to.have.lengthOf(1)
887 const deletedComment = firstChild.children[0].comment
888 expect(deletedComment.isDeleted).to.be.true
889 expect(deletedComment.deletedAt).to.not.be.null
890 expect(deletedComment.account).to.be.null
891 expect(deletedComment.text).to.equal('')
893 const secondChild = tree.children[1]
894 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
898 it('Should delete the thread comments', async function () {
901 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
902 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
903 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
905 await waitJobs(servers)
908 it('Should have the threads marked as deleted on other servers too', async function () {
909 for (const server of servers) {
910 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
912 expect(res.body.total).to.equal(2)
913 expect(res.body.data).to.be.an('array')
914 expect(res.body.data).to.have.lengthOf(2)
917 const comment: VideoComment = res.body.data[0]
918 expect(comment).to.not.be.undefined
919 expect(comment.inReplyToCommentId).to.be.null
920 expect(comment.account.name).to.equal('root')
921 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
922 expect(comment.totalReplies).to.equal(0)
923 expect(dateIsValid(comment.createdAt as string)).to.be.true
924 expect(dateIsValid(comment.updatedAt as string)).to.be.true
928 const deletedComment: VideoComment = res.body.data[1]
929 expect(deletedComment).to.not.be.undefined
930 expect(deletedComment.isDeleted).to.be.true
931 expect(deletedComment.deletedAt).to.not.be.null
932 expect(deletedComment.text).to.equal('')
933 expect(deletedComment.inReplyToCommentId).to.be.null
934 expect(deletedComment.account).to.be.null
935 expect(deletedComment.totalReplies).to.equal(2)
936 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
937 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
938 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
943 it('Should delete a remote thread by the origin server', async function () {
946 const res = await getVideoCommentThreads(servers[0].url, videoUUID, 0, 5)
947 const threadId = res.body.data.find(c => c.text === 'my super second comment').id
948 await deleteVideoComment(servers[0].url, servers[0].accessToken, videoUUID, threadId)
950 await waitJobs(servers)
953 it('Should have the threads marked as deleted on other servers too', async function () {
954 for (const server of servers) {
955 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
957 expect(res.body.total).to.equal(2)
958 expect(res.body.data).to.have.lengthOf(2)
961 const comment: VideoComment = res.body.data[0]
962 expect(comment.text).to.equal('')
963 expect(comment.isDeleted).to.be.true
964 expect(comment.createdAt).to.not.be.null
965 expect(comment.deletedAt).to.not.be.null
966 expect(comment.account).to.be.null
967 expect(comment.totalReplies).to.equal(0)
971 const comment: VideoComment = res.body.data[1]
972 expect(comment.text).to.equal('')
973 expect(comment.isDeleted).to.be.true
974 expect(comment.createdAt).to.not.be.null
975 expect(comment.deletedAt).to.not.be.null
976 expect(comment.account).to.be.null
977 expect(comment.totalReplies).to.equal(2)
982 it('Should disable comments and download', async function () {
986 commentsEnabled: false,
987 downloadEnabled: false
990 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
992 await waitJobs(servers)
994 for (const server of servers) {
995 const res = await getVideo(server.url, videoUUID)
996 expect(res.body.commentsEnabled).to.be.false
997 expect(res.body.downloadEnabled).to.be.false
999 const text = 'my super forbidden comment'
1000 await addVideoCommentThread(server.url, server.accessToken, videoUUID, text, HttpStatusCode.CONFLICT_409)
1005 describe('With minimum parameters', function () {
1006 it('Should upload and propagate the video', async function () {
1009 const path = '/api/v1/videos/upload'
1011 const req = request(servers[1].url)
1013 .set('Accept', 'application/json')
1014 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1015 .field('name', 'minimum parameters')
1016 .field('privacy', '1')
1017 .field('channelId', '1')
1019 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1020 .expect(HttpStatusCode.OK_200)
1022 await waitJobs(servers)
1024 for (const server of servers) {
1025 const res = await getVideosList(server.url)
1026 const video = res.body.data.find(v => v.name === 'minimum parameters')
1028 const isLocal = server.url === 'http://localhost:' + servers[1].port
1029 const checkAttributes = {
1030 name: 'minimum parameters',
1039 host: 'localhost:' + servers[1].port
1043 commentsEnabled: true,
1044 downloadEnabled: true,
1046 privacy: VideoPrivacy.PUBLIC,
1048 displayName: 'Main root channel',
1049 name: 'root_channel',
1053 fixture: 'video_short.webm',
1073 await completeVideoCheck(server.url, video, checkAttributes)
1078 describe('TMP directory', function () {
1079 it('Should have an empty tmp directory', async function () {
1080 for (const server of servers) {
1081 await checkTmpIsEmpty(server)
1086 after(async function () {
1087 await cleanupTests(servers)