1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import request from 'supertest'
7 buildAbsoluteFixturePath,
9 checkVideoFilesWereRemoved,
12 createMultipleServers,
17 setAccessTokensToServers,
22 } from '@shared/extra-utils'
23 import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
25 const expect = chai.expect
27 describe('Test multiple servers', function () {
28 let servers: PeerTubeServer[] = []
31 let videoChannelId: number
33 before(async function () {
36 servers = await createMultipleServers(3)
38 // Get the access tokens
39 await setAccessTokensToServers(servers)
42 const videoChannel = {
43 name: 'super_channel_name',
44 displayName: 'my channel',
45 description: 'super channel'
47 await servers[0].channels.create({ attributes: videoChannel })
48 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
49 videoChannelId = data[0].id
52 // Server 1 and server 2 follow each other
53 await doubleFollow(servers[0], servers[1])
54 // Server 1 and server 3 follow each other
55 await doubleFollow(servers[0], servers[2])
56 // Server 2 and server 3 follow each other
57 await doubleFollow(servers[1], servers[2])
60 it('Should not have videos for all servers', async function () {
61 for (const server of servers) {
62 const { data } = await server.videos.list()
63 expect(data).to.be.an('array')
64 expect(data.length).to.equal(0)
68 describe('Should upload the video and propagate on each server', function () {
69 it('Should upload the video on server 1 and propagate on each server', async function () {
73 name: 'my super name for server 1',
78 description: 'my super description for server 1',
79 support: 'my super support text for server 1',
80 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
81 tags: [ 'tag1p1', 'tag2p1' ],
82 channelId: videoChannelId,
83 fixture: 'video_short1.webm'
85 await servers[0].videos.upload({ attributes })
87 await waitJobs(servers)
89 // All servers should have this video
90 let publishedAt: string = null
91 for (const server of servers) {
92 const isLocal = server.port === servers[0].port
93 const checkAttributes = {
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 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
104 host: 'localhost:' + servers[0].port
109 tags: [ 'tag1p1', 'tag2p1' ],
110 privacy: VideoPrivacy.PUBLIC,
111 commentsEnabled: true,
112 downloadEnabled: true,
114 displayName: 'my channel',
115 name: 'super_channel_name',
116 description: 'super channel',
119 fixture: 'video_short1.webm',
128 const { data } = await server.videos.list()
129 expect(data).to.be.an('array')
130 expect(data.length).to.equal(1)
131 const video = data[0]
133 await completeVideoCheck(server, video, checkAttributes)
134 publishedAt = video.publishedAt as string
138 it('Should upload the video on server 2 and propagate on each server', async function () {
143 password: 'super_password'
145 await servers[1].users.create({ username: user.username, password: user.password })
146 const userAccessToken = await servers[1].login.getAccessToken(user)
149 name: 'my super name for server 2',
154 description: 'my super description for server 2',
155 support: 'my super support text for server 2',
156 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
157 fixture: 'video_short2.webm',
158 thumbnailfile: 'thumbnail.jpg',
159 previewfile: 'preview.jpg'
161 await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
164 await waitJobs(servers)
166 // All servers should have this video
167 for (const server of servers) {
168 const isLocal = server.url === 'http://localhost:' + servers[1].port
169 const checkAttributes = {
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',
179 host: 'localhost:' + servers[1].port
182 commentsEnabled: true,
183 downloadEnabled: true,
185 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
186 privacy: VideoPrivacy.PUBLIC,
188 displayName: 'Main user1 channel',
189 name: 'user1_channel',
190 description: 'super channel',
193 fixture: 'video_short2.webm',
212 thumbnailfile: 'thumbnail',
213 previewfile: 'preview'
216 const { data } = await server.videos.list()
217 expect(data).to.be.an('array')
218 expect(data.length).to.equal(2)
219 const video = data[1]
221 await completeVideoCheck(server, video, checkAttributes)
225 it('Should upload two videos on server 3 and propagate on each server', async function () {
230 name: 'my super name for server 3',
235 description: 'my super description for server 3',
236 support: 'my super support text for server 3',
238 fixture: 'video_short3.webm'
240 await servers[2].videos.upload({ attributes })
245 name: 'my super name for server 3-2',
250 description: 'my super description for server 3-2',
251 support: 'my super support text for server 3-2',
252 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
253 fixture: 'video_short.webm'
255 await servers[2].videos.upload({ attributes })
258 await waitJobs(servers)
260 // All servers should have this video
261 for (const server of servers) {
262 const isLocal = server.url === 'http://localhost:' + servers[2].port
263 const { data } = await server.videos.list()
265 expect(data).to.be.an('array')
266 expect(data.length).to.equal(4)
268 // We not sure about the order of the two last uploads
271 if (data[2].name === 'my super name for server 3') {
279 const checkAttributesVideo1 = {
280 name: 'my super name for server 3',
285 description: 'my super description for server 3',
286 support: 'my super support text for server 3',
289 host: 'localhost:' + servers[2].port
293 commentsEnabled: true,
294 downloadEnabled: true,
296 privacy: VideoPrivacy.PUBLIC,
298 displayName: 'Main root channel',
299 name: 'root_channel',
303 fixture: 'video_short3.webm',
311 await completeVideoCheck(server, video1, checkAttributesVideo1)
313 const checkAttributesVideo2 = {
314 name: 'my super name for server 3-2',
319 description: 'my super description for server 3-2',
320 support: 'my super support text for server 3-2',
323 host: 'localhost:' + servers[2].port
325 commentsEnabled: true,
326 downloadEnabled: true,
329 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
330 privacy: VideoPrivacy.PUBLIC,
332 displayName: 'Main root channel',
333 name: 'root_channel',
337 fixture: 'video_short.webm',
345 await completeVideoCheck(server, video2, checkAttributesVideo2)
350 describe('It should list local videos', function () {
351 it('Should list only local videos on server 1', async function () {
352 const { data, total } = await servers[0].videos.list({ isLocal: true })
354 expect(total).to.equal(1)
355 expect(data).to.be.an('array')
356 expect(data.length).to.equal(1)
357 expect(data[0].name).to.equal('my super name for server 1')
360 it('Should list only local videos on server 2', async function () {
361 const { data, total } = await servers[1].videos.list({ isLocal: true })
363 expect(total).to.equal(1)
364 expect(data).to.be.an('array')
365 expect(data.length).to.equal(1)
366 expect(data[0].name).to.equal('my super name for server 2')
369 it('Should list only local videos on server 3', async function () {
370 const { data, total } = await servers[2].videos.list({ isLocal: true })
372 expect(total).to.equal(2)
373 expect(data).to.be.an('array')
374 expect(data.length).to.equal(2)
375 expect(data[0].name).to.equal('my super name for server 3')
376 expect(data[1].name).to.equal('my super name for server 3-2')
380 describe('Should seed the uploaded video', function () {
381 it('Should add the file 1 by asking server 3', async function () {
384 const { data } = await servers[2].videos.list()
386 const video = data[0]
387 toRemove.push(data[2])
388 toRemove.push(data[3])
390 const videoDetails = await servers[2].videos.get({ id: video.id })
391 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
392 expect(torrent.files).to.be.an('array')
393 expect(torrent.files.length).to.equal(1)
394 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
397 it('Should add the file 2 by asking server 1', async function () {
400 const { data } = await servers[0].videos.list()
402 const video = data[1]
403 const videoDetails = await servers[0].videos.get({ id: video.id })
405 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
406 expect(torrent.files).to.be.an('array')
407 expect(torrent.files.length).to.equal(1)
408 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
411 it('Should add the file 3 by asking server 2', async function () {
414 const { data } = await servers[1].videos.list()
416 const video = data[2]
417 const videoDetails = await servers[1].videos.get({ id: video.id })
419 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
420 expect(torrent.files).to.be.an('array')
421 expect(torrent.files.length).to.equal(1)
422 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
425 it('Should add the file 3-2 by asking server 1', async function () {
428 const { data } = await servers[0].videos.list()
430 const video = data[3]
431 const videoDetails = await servers[0].videos.get({ id: video.id })
433 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
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 2 in 360p by asking server 1', async function () {
442 const { data } = await servers[0].videos.list()
444 const video = data.find(v => v.name === 'my super name for server 2')
445 const videoDetails = await servers[0].videos.get({ id: video.id })
447 const file = videoDetails.files.find(f => f.resolution.id === 360)
448 expect(file).not.to.be.undefined
450 const torrent = await webtorrentAdd(file.magnetUri)
451 expect(torrent.files).to.be.an('array')
452 expect(torrent.files.length).to.equal(1)
453 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
457 describe('Should update video views, likes and dislikes', function () {
458 let localVideosServer3 = []
459 let remoteVideosServer1 = []
460 let remoteVideosServer2 = []
461 let remoteVideosServer3 = []
463 before(async function () {
465 const { data } = await servers[0].videos.list()
466 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
470 const { data } = await servers[1].videos.list()
471 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
475 const { data } = await servers[2].videos.list()
476 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
477 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
481 it('Should view multiple videos on owned servers', async function () {
484 await servers[2].videos.view({ id: localVideosServer3[0] })
487 await servers[2].videos.view({ id: localVideosServer3[0] })
488 await servers[2].videos.view({ id: localVideosServer3[1] })
492 await servers[2].videos.view({ id: localVideosServer3[0] })
493 await servers[2].videos.view({ id: localVideosServer3[0] })
495 await waitJobs(servers)
497 // Wait the repeatable job
500 await waitJobs(servers)
502 for (const server of servers) {
503 const { data } = await server.videos.list()
505 const video0 = data.find(v => v.uuid === localVideosServer3[0])
506 const video1 = data.find(v => v.uuid === localVideosServer3[1])
508 expect(video0.views).to.equal(3)
509 expect(video1.views).to.equal(1)
513 it('Should view multiple videos on each servers', async function () {
516 const tasks: Promise<any>[] = []
517 tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] }))
518 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
519 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
520 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] }))
521 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
522 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
523 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
524 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
525 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
526 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
528 await Promise.all(tasks)
530 await waitJobs(servers)
532 // Wait the repeatable job
535 await waitJobs(servers)
537 let baseVideos = null
539 for (const server of servers) {
540 const { data } = await server.videos.list()
542 // Initialize base videos for future comparisons
543 if (baseVideos === null) {
548 for (const baseVideo of baseVideos) {
549 const sameVideo = data.find(video => video.name === baseVideo.name)
550 expect(baseVideo.views).to.equal(sameVideo.views)
555 it('Should like and dislikes videos on different services', async function () {
558 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
560 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
562 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
563 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
565 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
566 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
568 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
570 await waitJobs(servers)
572 await waitJobs(servers)
574 let baseVideos = null
575 for (const server of servers) {
576 const { data } = await server.videos.list()
578 // Initialize base videos for future comparisons
579 if (baseVideos === null) {
584 for (const baseVideo of baseVideos) {
585 const sameVideo = data.find(video => video.name === baseVideo.name)
586 expect(baseVideo.likes).to.equal(sameVideo.likes)
587 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
593 describe('Should manipulate these videos', function () {
594 it('Should update the video 3 by asking server 3', async function () {
598 name: 'my super video updated',
603 description: 'my super description updated',
604 support: 'my super support text updated',
605 tags: [ 'tag_up_1', 'tag_up_2' ],
606 thumbnailfile: 'thumbnail.jpg',
607 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
608 previewfile: 'preview.jpg'
611 await servers[2].videos.update({ id: toRemove[0].id, attributes })
613 await waitJobs(servers)
616 it('Should have the video 3 updated on each server', async function () {
619 for (const server of servers) {
620 const { data } = await server.videos.list()
622 const videoUpdated = data.find(video => video.name === 'my super video updated')
623 expect(!!videoUpdated).to.be.true
625 const isLocal = server.url === 'http://localhost:' + servers[2].port
626 const checkAttributes = {
627 name: 'my super video updated',
632 description: 'my super description updated',
633 support: 'my super support text updated',
634 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
637 host: 'localhost:' + servers[2].port
641 commentsEnabled: true,
642 downloadEnabled: true,
643 tags: [ 'tag_up_1', 'tag_up_2' ],
644 privacy: VideoPrivacy.PUBLIC,
646 displayName: 'Main root channel',
647 name: 'root_channel',
651 fixture: 'video_short3.webm',
658 thumbnailfile: 'thumbnail',
659 previewfile: 'preview'
661 await completeVideoCheck(server, videoUpdated, checkAttributes)
665 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
668 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
669 await saveVideoInServers(servers, id)
671 await servers[2].videos.remove({ id })
673 await waitJobs(servers)
675 for (const server of servers) {
676 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
681 it('Should have videos 1 and 3 on each server', async function () {
682 for (const server of servers) {
683 const { data } = await server.videos.list()
685 expect(data).to.be.an('array')
686 expect(data.length).to.equal(2)
687 expect(data[0].name).not.to.equal(data[1].name)
688 expect(data[0].name).not.to.equal(toRemove[0].name)
689 expect(data[1].name).not.to.equal(toRemove[0].name)
690 expect(data[0].name).not.to.equal(toRemove[1].name)
691 expect(data[1].name).not.to.equal(toRemove[1].name)
693 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
697 it('Should get the same video by UUID on each server', async function () {
699 for (const server of servers) {
700 const video = await server.videos.get({ id: videoUUID })
702 if (baseVideo === null) {
707 expect(baseVideo.name).to.equal(video.name)
708 expect(baseVideo.uuid).to.equal(video.uuid)
709 expect(baseVideo.category.id).to.equal(video.category.id)
710 expect(baseVideo.language.id).to.equal(video.language.id)
711 expect(baseVideo.licence.id).to.equal(video.licence.id)
712 expect(baseVideo.nsfw).to.equal(video.nsfw)
713 expect(baseVideo.account.name).to.equal(video.account.name)
714 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
715 expect(baseVideo.account.url).to.equal(video.account.url)
716 expect(baseVideo.account.host).to.equal(video.account.host)
717 expect(baseVideo.tags).to.deep.equal(video.tags)
721 it('Should get the preview from each server', async function () {
722 for (const server of servers) {
723 const video = await server.videos.get({ id: videoUUID })
725 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
730 describe('Should comment these videos', function () {
731 let childOfFirstChild: VideoCommentThreadTree
733 it('Should add comment (threads and replies)', async function () {
737 const text = 'my super first comment'
738 await servers[0].comments.createThread({ videoId: videoUUID, text })
742 const text = 'my super second comment'
743 await servers[2].comments.createThread({ videoId: videoUUID, text })
746 await waitJobs(servers)
749 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
751 const text = 'my super answer to thread 1'
752 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
755 await waitJobs(servers)
758 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
760 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
761 const childCommentId = body.children[0].comment.id
763 const text3 = 'my second answer to thread 1'
764 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
766 const text2 = 'my super answer to answer of thread 1'
767 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
770 await waitJobs(servers)
773 it('Should have these threads', async function () {
774 for (const server of servers) {
775 const body = await server.comments.listThreads({ videoId: videoUUID })
777 expect(body.total).to.equal(2)
778 expect(body.data).to.be.an('array')
779 expect(body.data).to.have.lengthOf(2)
782 const comment = body.data.find(c => c.text === 'my super first comment')
783 expect(comment).to.not.be.undefined
784 expect(comment.inReplyToCommentId).to.be.null
785 expect(comment.account.name).to.equal('root')
786 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
787 expect(comment.totalReplies).to.equal(3)
788 expect(dateIsValid(comment.createdAt as string)).to.be.true
789 expect(dateIsValid(comment.updatedAt as string)).to.be.true
793 const comment = body.data.find(c => c.text === 'my super second comment')
794 expect(comment).to.not.be.undefined
795 expect(comment.inReplyToCommentId).to.be.null
796 expect(comment.account.name).to.equal('root')
797 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
798 expect(comment.totalReplies).to.equal(0)
799 expect(dateIsValid(comment.createdAt as string)).to.be.true
800 expect(dateIsValid(comment.updatedAt as string)).to.be.true
805 it('Should have these comments', async function () {
806 for (const server of servers) {
807 const body = await server.comments.listThreads({ videoId: videoUUID })
808 const threadId = body.data.find(c => c.text === 'my super first comment').id
810 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
812 expect(tree.comment.text).equal('my super first comment')
813 expect(tree.comment.account.name).equal('root')
814 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
815 expect(tree.children).to.have.lengthOf(2)
817 const firstChild = tree.children[0]
818 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
819 expect(firstChild.comment.account.name).equal('root')
820 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
821 expect(firstChild.children).to.have.lengthOf(1)
823 childOfFirstChild = firstChild.children[0]
824 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
825 expect(childOfFirstChild.comment.account.name).equal('root')
826 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
827 expect(childOfFirstChild.children).to.have.lengthOf(0)
829 const secondChild = tree.children[1]
830 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
831 expect(secondChild.comment.account.name).equal('root')
832 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
833 expect(secondChild.children).to.have.lengthOf(0)
837 it('Should delete a reply', async function () {
840 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
842 await waitJobs(servers)
845 it('Should have this comment marked as deleted', async function () {
846 for (const server of servers) {
847 const { data } = await server.comments.listThreads({ videoId: videoUUID })
848 const threadId = data.find(c => c.text === 'my super first comment').id
850 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
851 expect(tree.comment.text).equal('my super first comment')
853 const firstChild = tree.children[0]
854 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
855 expect(firstChild.children).to.have.lengthOf(1)
857 const deletedComment = firstChild.children[0].comment
858 expect(deletedComment.isDeleted).to.be.true
859 expect(deletedComment.deletedAt).to.not.be.null
860 expect(deletedComment.account).to.be.null
861 expect(deletedComment.text).to.equal('')
863 const secondChild = tree.children[1]
864 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
868 it('Should delete the thread comments', async function () {
871 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
872 const commentId = data.find(c => c.text === 'my super first comment').id
873 await servers[0].comments.delete({ videoId: videoUUID, commentId })
875 await waitJobs(servers)
878 it('Should have the threads marked as deleted on other servers too', async function () {
879 for (const server of servers) {
880 const body = await server.comments.listThreads({ videoId: videoUUID })
882 expect(body.total).to.equal(2)
883 expect(body.data).to.be.an('array')
884 expect(body.data).to.have.lengthOf(2)
887 const comment = body.data[0]
888 expect(comment).to.not.be.undefined
889 expect(comment.inReplyToCommentId).to.be.null
890 expect(comment.account.name).to.equal('root')
891 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
892 expect(comment.totalReplies).to.equal(0)
893 expect(dateIsValid(comment.createdAt as string)).to.be.true
894 expect(dateIsValid(comment.updatedAt as string)).to.be.true
898 const deletedComment = body.data[1]
899 expect(deletedComment).to.not.be.undefined
900 expect(deletedComment.isDeleted).to.be.true
901 expect(deletedComment.deletedAt).to.not.be.null
902 expect(deletedComment.text).to.equal('')
903 expect(deletedComment.inReplyToCommentId).to.be.null
904 expect(deletedComment.account).to.be.null
905 expect(deletedComment.totalReplies).to.equal(2)
906 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
907 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
908 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
913 it('Should delete a remote thread by the origin server', async function () {
916 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
917 const commentId = data.find(c => c.text === 'my super second comment').id
918 await servers[0].comments.delete({ videoId: videoUUID, commentId })
920 await waitJobs(servers)
923 it('Should have the threads marked as deleted on other servers too', async function () {
924 for (const server of servers) {
925 const body = await server.comments.listThreads({ videoId: videoUUID })
927 expect(body.total).to.equal(2)
928 expect(body.data).to.have.lengthOf(2)
931 const comment = body.data[0]
932 expect(comment.text).to.equal('')
933 expect(comment.isDeleted).to.be.true
934 expect(comment.createdAt).to.not.be.null
935 expect(comment.deletedAt).to.not.be.null
936 expect(comment.account).to.be.null
937 expect(comment.totalReplies).to.equal(0)
941 const comment = body.data[1]
942 expect(comment.text).to.equal('')
943 expect(comment.isDeleted).to.be.true
944 expect(comment.createdAt).to.not.be.null
945 expect(comment.deletedAt).to.not.be.null
946 expect(comment.account).to.be.null
947 expect(comment.totalReplies).to.equal(2)
952 it('Should disable comments and download', async function () {
956 commentsEnabled: false,
957 downloadEnabled: false
960 await servers[0].videos.update({ id: videoUUID, attributes })
962 await waitJobs(servers)
964 for (const server of servers) {
965 const video = await server.videos.get({ id: videoUUID })
966 expect(video.commentsEnabled).to.be.false
967 expect(video.downloadEnabled).to.be.false
969 const text = 'my super forbidden comment'
970 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
975 describe('With minimum parameters', function () {
976 it('Should upload and propagate the video', async function () {
979 const path = '/api/v1/videos/upload'
981 const req = request(servers[1].url)
983 .set('Accept', 'application/json')
984 .set('Authorization', 'Bearer ' + servers[1].accessToken)
985 .field('name', 'minimum parameters')
986 .field('privacy', '1')
987 .field('channelId', '1')
989 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
990 .expect(HttpStatusCode.OK_200)
992 await waitJobs(servers)
994 for (const server of servers) {
995 const { data } = await server.videos.list()
996 const video = data.find(v => v.name === 'minimum parameters')
998 const isLocal = server.url === 'http://localhost:' + servers[1].port
999 const checkAttributes = {
1000 name: 'minimum parameters',
1009 host: 'localhost:' + servers[1].port
1013 commentsEnabled: true,
1014 downloadEnabled: true,
1016 privacy: VideoPrivacy.PUBLIC,
1018 displayName: 'Main root channel',
1019 name: 'root_channel',
1023 fixture: 'video_short.webm',
1043 await completeVideoCheck(server, video, checkAttributes)
1048 describe('TMP directory', function () {
1049 it('Should have an empty tmp directory', async function () {
1050 for (const server of servers) {
1051 await checkTmpIsEmpty(server)
1056 after(async function () {
1057 await cleanupTests(servers)