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'
8 buildAbsoluteFixturePath,
10 checkVideoFilesWereRemoved,
16 flushAndRunMultipleServers,
23 setAccessTokensToServers,
32 } from '@shared/extra-utils'
33 import { VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
35 const expect = chai.expect
37 describe('Test multiple servers', function () {
38 let servers: ServerInfo[] = []
41 let videoChannelId: number
43 before(async function () {
46 servers = await flushAndRunMultipleServers(3)
48 // Get the access tokens
49 await setAccessTokensToServers(servers)
52 const videoChannel = {
53 name: 'super_channel_name',
54 displayName: 'my channel',
55 description: 'super channel'
57 await servers[0].channelsCommand.create({ attributes: videoChannel })
58 const { data } = await servers[0].channelsCommand.list({ start: 0, count: 1 })
59 videoChannelId = data[0].id
62 // Server 1 and server 2 follow each other
63 await doubleFollow(servers[0], servers[1])
64 // Server 1 and server 3 follow each other
65 await doubleFollow(servers[0], servers[2])
66 // Server 2 and server 3 follow each other
67 await doubleFollow(servers[1], servers[2])
70 it('Should not have videos for all servers', async function () {
71 for (const server of servers) {
72 const res = await getVideosList(server.url)
73 const videos = res.body.data
74 expect(videos).to.be.an('array')
75 expect(videos.length).to.equal(0)
79 describe('Should upload the video and propagate on each server', function () {
80 it('Should upload the video on server 1 and propagate on each server', async function () {
83 const videoAttributes = {
84 name: 'my super name for server 1',
89 description: 'my super description for server 1',
90 support: 'my super support text for server 1',
91 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
92 tags: [ 'tag1p1', 'tag2p1' ],
93 channelId: videoChannelId,
94 fixture: 'video_short1.webm'
96 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
98 await waitJobs(servers)
100 // All servers should have this video
101 let publishedAt: string = null
102 for (const server of servers) {
103 const isLocal = server.port === servers[0].port
104 const checkAttributes = {
105 name: 'my super name for server 1',
110 description: 'my super description for server 1',
111 support: 'my super support text for server 1',
112 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
115 host: 'localhost:' + servers[0].port
120 tags: [ 'tag1p1', 'tag2p1' ],
121 privacy: VideoPrivacy.PUBLIC,
122 commentsEnabled: true,
123 downloadEnabled: true,
125 displayName: 'my channel',
126 name: 'super_channel_name',
127 description: 'super channel',
130 fixture: 'video_short1.webm',
139 const res = await getVideosList(server.url)
140 const videos = res.body.data
141 expect(videos).to.be.an('array')
142 expect(videos.length).to.equal(1)
143 const video = videos[0]
145 await completeVideoCheck(server.url, video, checkAttributes)
146 publishedAt = video.publishedAt
150 it('Should upload the video on server 2 and propagate on each server', async function () {
155 password: 'super_password'
157 await createUser({ url: servers[1].url, accessToken: servers[1].accessToken, username: user.username, password: user.password })
158 const userAccessToken = await userLogin(servers[1], user)
160 const videoAttributes = {
161 name: 'my super name for server 2',
166 description: 'my super description for server 2',
167 support: 'my super support text for server 2',
168 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
169 fixture: 'video_short2.webm',
170 thumbnailfile: 'thumbnail.jpg',
171 previewfile: 'preview.jpg'
173 await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable')
176 await waitJobs(servers)
178 // All servers should have this video
179 for (const server of servers) {
180 const isLocal = server.url === 'http://localhost:' + servers[1].port
181 const checkAttributes = {
182 name: 'my super name for server 2',
187 description: 'my super description for server 2',
188 support: 'my super support text for server 2',
191 host: 'localhost:' + servers[1].port
194 commentsEnabled: true,
195 downloadEnabled: true,
197 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
198 privacy: VideoPrivacy.PUBLIC,
200 displayName: 'Main user1 channel',
201 name: 'user1_channel',
202 description: 'super channel',
205 fixture: 'video_short2.webm',
224 thumbnailfile: 'thumbnail',
225 previewfile: 'preview'
228 const res = await getVideosList(server.url)
229 const videos = res.body.data
230 expect(videos).to.be.an('array')
231 expect(videos.length).to.equal(2)
232 const video = videos[1]
234 await completeVideoCheck(server.url, video, checkAttributes)
238 it('Should upload two videos on server 3 and propagate on each server', async function () {
241 const videoAttributes1 = {
242 name: 'my super name for server 3',
247 description: 'my super description for server 3',
248 support: 'my super support text for server 3',
250 fixture: 'video_short3.webm'
252 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
254 const videoAttributes2 = {
255 name: 'my super name for server 3-2',
260 description: 'my super description for server 3-2',
261 support: 'my super support text for server 3-2',
262 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
263 fixture: 'video_short.webm'
265 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
267 await waitJobs(servers)
269 // All servers should have this video
270 for (const server of servers) {
271 const isLocal = server.url === 'http://localhost:' + servers[2].port
272 const res = await getVideosList(server.url)
274 const videos = res.body.data
275 expect(videos).to.be.an('array')
276 expect(videos.length).to.equal(4)
278 // We not sure about the order of the two last uploads
281 if (videos[2].name === 'my super name for server 3') {
289 const checkAttributesVideo1 = {
290 name: 'my super name for server 3',
295 description: 'my super description for server 3',
296 support: 'my super support text for server 3',
299 host: 'localhost:' + servers[2].port
303 commentsEnabled: true,
304 downloadEnabled: true,
306 privacy: VideoPrivacy.PUBLIC,
308 displayName: 'Main root channel',
309 name: 'root_channel',
313 fixture: 'video_short3.webm',
321 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
323 const checkAttributesVideo2 = {
324 name: 'my super name for server 3-2',
329 description: 'my super description for server 3-2',
330 support: 'my super support text for server 3-2',
333 host: 'localhost:' + servers[2].port
335 commentsEnabled: true,
336 downloadEnabled: true,
339 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
340 privacy: VideoPrivacy.PUBLIC,
342 displayName: 'Main root channel',
343 name: 'root_channel',
347 fixture: 'video_short.webm',
355 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
360 describe('It should list local videos', function () {
361 it('Should list only local videos on server 1', async function () {
362 const { body } = await getLocalVideos(servers[0].url)
364 expect(body.total).to.equal(1)
365 expect(body.data).to.be.an('array')
366 expect(body.data.length).to.equal(1)
367 expect(body.data[0].name).to.equal('my super name for server 1')
370 it('Should list only local videos on server 2', async function () {
371 const { body } = await getLocalVideos(servers[1].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 2')
379 it('Should list only local videos on server 3', async function () {
380 const { body } = await getLocalVideos(servers[2].url)
382 expect(body.total).to.equal(2)
383 expect(body.data).to.be.an('array')
384 expect(body.data.length).to.equal(2)
385 expect(body.data[0].name).to.equal('my super name for server 3')
386 expect(body.data[1].name).to.equal('my super name for server 3-2')
390 describe('Should seed the uploaded video', function () {
391 it('Should add the file 1 by asking server 3', async function () {
394 const res = await getVideosList(servers[2].url)
396 const video = res.body.data[0]
397 toRemove.push(res.body.data[2])
398 toRemove.push(res.body.data[3])
400 const res2 = await getVideo(servers[2].url, video.id)
401 const videoDetails = res2.body
403 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
404 expect(torrent.files).to.be.an('array')
405 expect(torrent.files.length).to.equal(1)
406 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
409 it('Should add the file 2 by asking server 1', async function () {
412 const res = await getVideosList(servers[0].url)
414 const video = res.body.data[1]
415 const res2 = await getVideo(servers[0].url, video.id)
416 const videoDetails = res2.body
418 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
419 expect(torrent.files).to.be.an('array')
420 expect(torrent.files.length).to.equal(1)
421 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
424 it('Should add the file 3 by asking server 2', async function () {
427 const res = await getVideosList(servers[1].url)
429 const video = res.body.data[2]
430 const res2 = await getVideo(servers[1].url, video.id)
431 const videoDetails = res2.body
433 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
434 expect(torrent.files).to.be.an('array')
435 expect(torrent.files.length).to.equal(1)
436 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
439 it('Should add the file 3-2 by asking server 1', async function () {
442 const res = await getVideosList(servers[0].url)
444 const video = res.body.data[3]
445 const res2 = await getVideo(servers[0].url, video.id)
446 const videoDetails = res2.body
448 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
449 expect(torrent.files).to.be.an('array')
450 expect(torrent.files.length).to.equal(1)
451 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
454 it('Should add the file 2 in 360p by asking server 1', async function () {
457 const res = await getVideosList(servers[0].url)
459 const video = res.body.data.find(v => v.name === 'my super name for server 2')
460 const res2 = await getVideo(servers[0].url, video.id)
461 const videoDetails = res2.body
463 const file = videoDetails.files.find(f => f.resolution.id === 360)
464 expect(file).not.to.be.undefined
466 const torrent = await webtorrentAdd(file.magnetUri)
467 expect(torrent.files).to.be.an('array')
468 expect(torrent.files.length).to.equal(1)
469 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
473 describe('Should update video views, likes and dislikes', function () {
474 let localVideosServer3 = []
475 let remoteVideosServer1 = []
476 let remoteVideosServer2 = []
477 let remoteVideosServer3 = []
479 before(async function () {
480 const res1 = await getVideosList(servers[0].url)
481 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
483 const res2 = await getVideosList(servers[1].url)
484 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
486 const res3 = await getVideosList(servers[2].url)
487 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
488 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
491 it('Should view multiple videos on owned servers', async function () {
494 await viewVideo(servers[2].url, localVideosServer3[0])
497 await viewVideo(servers[2].url, localVideosServer3[0])
498 await viewVideo(servers[2].url, localVideosServer3[1])
502 await viewVideo(servers[2].url, localVideosServer3[0])
503 await viewVideo(servers[2].url, localVideosServer3[0])
505 await waitJobs(servers)
507 // Wait the repeatable job
510 await waitJobs(servers)
512 for (const server of servers) {
513 const res = await getVideosList(server.url)
515 const videos = res.body.data
516 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
517 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
519 expect(video0.views).to.equal(3)
520 expect(video1.views).to.equal(1)
524 it('Should view multiple videos on each servers', async function () {
527 const tasks: Promise<any>[] = []
528 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
529 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
530 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
531 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
532 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
533 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
534 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
535 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
536 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
537 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
539 await Promise.all(tasks)
541 await waitJobs(servers)
543 // Wait the repeatable job
546 await waitJobs(servers)
548 let baseVideos = null
550 for (const server of servers) {
551 const res = await getVideosList(server.url)
553 const videos = res.body.data
555 // Initialize base videos for future comparisons
556 if (baseVideos === null) {
561 for (const baseVideo of baseVideos) {
562 const sameVideo = videos.find(video => video.name === baseVideo.name)
563 expect(baseVideo.views).to.equal(sameVideo.views)
568 it('Should like and dislikes videos on different services', async function () {
571 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
573 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
575 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
576 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
578 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
579 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
581 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
583 await waitJobs(servers)
585 await waitJobs(servers)
587 let baseVideos = null
588 for (const server of servers) {
589 const res = await getVideosList(server.url)
591 const videos = res.body.data
593 // Initialize base videos for future comparisons
594 if (baseVideos === null) {
599 for (const baseVideo of baseVideos) {
600 const sameVideo = videos.find(video => video.name === baseVideo.name)
601 expect(baseVideo.likes).to.equal(sameVideo.likes)
602 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
608 describe('Should manipulate these videos', function () {
609 it('Should update the video 3 by asking server 3', async function () {
613 name: 'my super video updated',
618 description: 'my super description updated',
619 support: 'my super support text updated',
620 tags: [ 'tag_up_1', 'tag_up_2' ],
621 thumbnailfile: 'thumbnail.jpg',
622 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
623 previewfile: 'preview.jpg'
626 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
628 await waitJobs(servers)
631 it('Should have the video 3 updated on each server', async function () {
634 for (const server of servers) {
635 const res = await getVideosList(server.url)
637 const videos = res.body.data
638 const videoUpdated = videos.find(video => video.name === 'my super video updated')
639 expect(!!videoUpdated).to.be.true
641 const isLocal = server.url === 'http://localhost:' + servers[2].port
642 const checkAttributes = {
643 name: 'my super video updated',
648 description: 'my super description updated',
649 support: 'my super support text updated',
650 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
653 host: 'localhost:' + servers[2].port
657 commentsEnabled: true,
658 downloadEnabled: true,
659 tags: [ 'tag_up_1', 'tag_up_2' ],
660 privacy: VideoPrivacy.PUBLIC,
662 displayName: 'Main root channel',
663 name: 'root_channel',
667 fixture: 'video_short3.webm',
674 thumbnailfile: 'thumbnail',
675 previewfile: 'preview'
677 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
681 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
684 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
685 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
687 await waitJobs(servers)
690 it('Should not have files of videos 3 and 3-2 on each server', async function () {
691 for (const server of servers) {
692 await checkVideoFilesWereRemoved(toRemove[0].uuid, server.internalServerNumber)
693 await checkVideoFilesWereRemoved(toRemove[1].uuid, server.internalServerNumber)
697 it('Should have videos 1 and 3 on each server', async function () {
698 for (const server of servers) {
699 const res = await getVideosList(server.url)
701 const videos = res.body.data
702 expect(videos).to.be.an('array')
703 expect(videos.length).to.equal(2)
704 expect(videos[0].name).not.to.equal(videos[1].name)
705 expect(videos[0].name).not.to.equal(toRemove[0].name)
706 expect(videos[1].name).not.to.equal(toRemove[0].name)
707 expect(videos[0].name).not.to.equal(toRemove[1].name)
708 expect(videos[1].name).not.to.equal(toRemove[1].name)
710 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
714 it('Should get the same video by UUID on each server', async function () {
716 for (const server of servers) {
717 const res = await getVideo(server.url, videoUUID)
719 const video = res.body
721 if (baseVideo === null) {
726 expect(baseVideo.name).to.equal(video.name)
727 expect(baseVideo.uuid).to.equal(video.uuid)
728 expect(baseVideo.category.id).to.equal(video.category.id)
729 expect(baseVideo.language.id).to.equal(video.language.id)
730 expect(baseVideo.licence.id).to.equal(video.licence.id)
731 expect(baseVideo.nsfw).to.equal(video.nsfw)
732 expect(baseVideo.account.name).to.equal(video.account.name)
733 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
734 expect(baseVideo.account.url).to.equal(video.account.url)
735 expect(baseVideo.account.host).to.equal(video.account.host)
736 expect(baseVideo.tags).to.deep.equal(video.tags)
740 it('Should get the preview from each server', async function () {
741 for (const server of servers) {
742 const res = await getVideo(server.url, videoUUID)
743 const video = res.body
745 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
750 describe('Should comment these videos', function () {
751 let childOfFirstChild: VideoCommentThreadTree
753 it('Should add comment (threads and replies)', async function () {
757 const text = 'my super first comment'
758 await servers[0].commentsCommand.createThread({ videoId: videoUUID, text })
762 const text = 'my super second comment'
763 await servers[2].commentsCommand.createThread({ videoId: videoUUID, text })
766 await waitJobs(servers)
769 const threadId = await servers[1].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
771 const text = 'my super answer to thread 1'
772 await servers[1].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text })
775 await waitJobs(servers)
778 const threadId = await servers[2].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
780 const body = await servers[2].commentsCommand.getThread({ videoId: videoUUID, threadId })
781 const childCommentId = body.children[0].comment.id
783 const text3 = 'my second answer to thread 1'
784 await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
786 const text2 = 'my super answer to answer of thread 1'
787 await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
790 await waitJobs(servers)
793 it('Should have these threads', async function () {
794 for (const server of servers) {
795 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
797 expect(body.total).to.equal(2)
798 expect(body.data).to.be.an('array')
799 expect(body.data).to.have.lengthOf(2)
802 const comment = body.data.find(c => c.text === 'my super first comment')
803 expect(comment).to.not.be.undefined
804 expect(comment.inReplyToCommentId).to.be.null
805 expect(comment.account.name).to.equal('root')
806 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
807 expect(comment.totalReplies).to.equal(3)
808 expect(dateIsValid(comment.createdAt as string)).to.be.true
809 expect(dateIsValid(comment.updatedAt as string)).to.be.true
813 const comment = body.data.find(c => c.text === 'my super second comment')
814 expect(comment).to.not.be.undefined
815 expect(comment.inReplyToCommentId).to.be.null
816 expect(comment.account.name).to.equal('root')
817 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
818 expect(comment.totalReplies).to.equal(0)
819 expect(dateIsValid(comment.createdAt as string)).to.be.true
820 expect(dateIsValid(comment.updatedAt as string)).to.be.true
825 it('Should have these comments', async function () {
826 for (const server of servers) {
827 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
828 const threadId = body.data.find(c => c.text === 'my super first comment').id
830 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId })
832 expect(tree.comment.text).equal('my super first comment')
833 expect(tree.comment.account.name).equal('root')
834 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
835 expect(tree.children).to.have.lengthOf(2)
837 const firstChild = tree.children[0]
838 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
839 expect(firstChild.comment.account.name).equal('root')
840 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
841 expect(firstChild.children).to.have.lengthOf(1)
843 childOfFirstChild = firstChild.children[0]
844 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
845 expect(childOfFirstChild.comment.account.name).equal('root')
846 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
847 expect(childOfFirstChild.children).to.have.lengthOf(0)
849 const secondChild = tree.children[1]
850 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
851 expect(secondChild.comment.account.name).equal('root')
852 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
853 expect(secondChild.children).to.have.lengthOf(0)
857 it('Should delete a reply', async function () {
860 await servers[2].commentsCommand.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
862 await waitJobs(servers)
865 it('Should have this comment marked as deleted', async function () {
866 for (const server of servers) {
867 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID })
868 const threadId = data.find(c => c.text === 'my super first comment').id
870 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId })
871 expect(tree.comment.text).equal('my super first comment')
873 const firstChild = tree.children[0]
874 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
875 expect(firstChild.children).to.have.lengthOf(1)
877 const deletedComment = firstChild.children[0].comment
878 expect(deletedComment.isDeleted).to.be.true
879 expect(deletedComment.deletedAt).to.not.be.null
880 expect(deletedComment.account).to.be.null
881 expect(deletedComment.text).to.equal('')
883 const secondChild = tree.children[1]
884 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
888 it('Should delete the thread comments', async function () {
891 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID })
892 const commentId = data.find(c => c.text === 'my super first comment').id
893 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId })
895 await waitJobs(servers)
898 it('Should have the threads marked as deleted on other servers too', async function () {
899 for (const server of servers) {
900 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
902 expect(body.total).to.equal(2)
903 expect(body.data).to.be.an('array')
904 expect(body.data).to.have.lengthOf(2)
907 const comment = body.data[0]
908 expect(comment).to.not.be.undefined
909 expect(comment.inReplyToCommentId).to.be.null
910 expect(comment.account.name).to.equal('root')
911 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
912 expect(comment.totalReplies).to.equal(0)
913 expect(dateIsValid(comment.createdAt as string)).to.be.true
914 expect(dateIsValid(comment.updatedAt as string)).to.be.true
918 const deletedComment = body.data[1]
919 expect(deletedComment).to.not.be.undefined
920 expect(deletedComment.isDeleted).to.be.true
921 expect(deletedComment.deletedAt).to.not.be.null
922 expect(deletedComment.text).to.equal('')
923 expect(deletedComment.inReplyToCommentId).to.be.null
924 expect(deletedComment.account).to.be.null
925 expect(deletedComment.totalReplies).to.equal(2)
926 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
927 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
928 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
933 it('Should delete a remote thread by the origin server', async function () {
936 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID })
937 const commentId = data.find(c => c.text === 'my super second comment').id
938 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId })
940 await waitJobs(servers)
943 it('Should have the threads marked as deleted on other servers too', async function () {
944 for (const server of servers) {
945 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
947 expect(body.total).to.equal(2)
948 expect(body.data).to.have.lengthOf(2)
951 const comment = body.data[0]
952 expect(comment.text).to.equal('')
953 expect(comment.isDeleted).to.be.true
954 expect(comment.createdAt).to.not.be.null
955 expect(comment.deletedAt).to.not.be.null
956 expect(comment.account).to.be.null
957 expect(comment.totalReplies).to.equal(0)
961 const comment = body.data[1]
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(2)
972 it('Should disable comments and download', async function () {
976 commentsEnabled: false,
977 downloadEnabled: false
980 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
982 await waitJobs(servers)
984 for (const server of servers) {
985 const res = await getVideo(server.url, videoUUID)
986 expect(res.body.commentsEnabled).to.be.false
987 expect(res.body.downloadEnabled).to.be.false
989 const text = 'my super forbidden comment'
990 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
995 describe('With minimum parameters', function () {
996 it('Should upload and propagate the video', async function () {
999 const path = '/api/v1/videos/upload'
1001 const req = request(servers[1].url)
1003 .set('Accept', 'application/json')
1004 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1005 .field('name', 'minimum parameters')
1006 .field('privacy', '1')
1007 .field('channelId', '1')
1009 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1010 .expect(HttpStatusCode.OK_200)
1012 await waitJobs(servers)
1014 for (const server of servers) {
1015 const res = await getVideosList(server.url)
1016 const video = res.body.data.find(v => v.name === 'minimum parameters')
1018 const isLocal = server.url === 'http://localhost:' + servers[1].port
1019 const checkAttributes = {
1020 name: 'minimum parameters',
1029 host: 'localhost:' + servers[1].port
1033 commentsEnabled: true,
1034 downloadEnabled: true,
1036 privacy: VideoPrivacy.PUBLIC,
1038 displayName: 'Main root channel',
1039 name: 'root_channel',
1043 fixture: 'video_short.webm',
1063 await completeVideoCheck(server.url, video, checkAttributes)
1068 describe('TMP directory', function () {
1069 it('Should have an empty tmp directory', async function () {
1070 for (const server of servers) {
1071 await checkTmpIsEmpty(server)
1076 after(async function () {
1077 await cleanupTests(servers)