1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import request from 'supertest'
8 checkVideoFilesWereRemoved,
13 } from '@server/tests/shared'
14 import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
15 import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
18 createMultipleServers,
21 setAccessTokensToServers,
22 setDefaultAccountAvatar,
23 setDefaultChannelAvatar,
26 } from '@shared/server-commands'
28 const expect = chai.expect
30 describe('Test multiple servers', function () {
31 let servers: PeerTubeServer[] = []
34 let videoChannelId: number
36 before(async function () {
39 servers = await createMultipleServers(3)
41 // Get the access tokens
42 await setAccessTokensToServers(servers)
45 const videoChannel = {
46 name: 'super_channel_name',
47 displayName: 'my channel',
48 description: 'super channel'
50 await servers[0].channels.create({ attributes: videoChannel })
51 await setDefaultChannelAvatar(servers[0], videoChannel.name)
52 await setDefaultAccountAvatar(servers)
54 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
55 videoChannelId = data[0].id
58 // Server 1 and server 2 follow each other
59 await doubleFollow(servers[0], servers[1])
60 // Server 1 and server 3 follow each other
61 await doubleFollow(servers[0], servers[2])
62 // Server 2 and server 3 follow each other
63 await doubleFollow(servers[1], servers[2])
66 it('Should not have videos for all servers', async function () {
67 for (const server of servers) {
68 const { data } = await server.videos.list()
69 expect(data).to.be.an('array')
70 expect(data.length).to.equal(0)
74 describe('Should upload the video and propagate on each server', function () {
75 it('Should upload the video on server 1 and propagate on each server', async function () {
79 name: 'my super name for server 1',
84 description: 'my super description for server 1',
85 support: 'my super support text for server 1',
86 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
87 tags: [ 'tag1p1', 'tag2p1' ],
88 channelId: videoChannelId,
89 fixture: 'video_short1.webm'
91 await servers[0].videos.upload({ attributes })
93 await waitJobs(servers)
95 // All servers should have this video
96 let publishedAt: string = null
97 for (const server of servers) {
98 const isLocal = server.port === servers[0].port
99 const checkAttributes = {
100 name: 'my super name for server 1',
105 description: 'my super description for server 1',
106 support: 'my super support text for server 1',
107 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
110 host: 'localhost:' + servers[0].port
115 tags: [ 'tag1p1', 'tag2p1' ],
116 privacy: VideoPrivacy.PUBLIC,
117 commentsEnabled: true,
118 downloadEnabled: true,
120 displayName: 'my channel',
121 name: 'super_channel_name',
122 description: 'super channel',
125 fixture: 'video_short1.webm',
134 const { data } = await server.videos.list()
135 expect(data).to.be.an('array')
136 expect(data.length).to.equal(1)
137 const video = data[0]
139 await completeVideoCheck(server, video, checkAttributes)
140 publishedAt = video.publishedAt as string
144 it('Should upload the video on server 2 and propagate on each server', async function () {
149 password: 'super_password'
151 await servers[1].users.create({ username: user.username, password: user.password })
152 const userAccessToken = await servers[1].login.getAccessToken(user)
155 name: 'my super name for server 2',
160 description: 'my super description for server 2',
161 support: 'my super support text for server 2',
162 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
163 fixture: 'video_short2.webm',
164 thumbnailfile: 'thumbnail.jpg',
165 previewfile: 'preview.jpg'
167 await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
170 await waitJobs(servers)
172 // All servers should have this video
173 for (const server of servers) {
174 const isLocal = server.url === 'http://localhost:' + servers[1].port
175 const checkAttributes = {
176 name: 'my super name for server 2',
181 description: 'my super description for server 2',
182 support: 'my super support text for server 2',
185 host: 'localhost:' + servers[1].port
188 commentsEnabled: true,
189 downloadEnabled: true,
191 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
192 privacy: VideoPrivacy.PUBLIC,
194 displayName: 'Main user1 channel',
195 name: 'user1_channel',
196 description: 'super channel',
199 fixture: 'video_short2.webm',
218 thumbnailfile: 'thumbnail',
219 previewfile: 'preview'
222 const { data } = await server.videos.list()
223 expect(data).to.be.an('array')
224 expect(data.length).to.equal(2)
225 const video = data[1]
227 await completeVideoCheck(server, video, checkAttributes)
231 it('Should upload two videos on server 3 and propagate on each server', async function () {
236 name: 'my super name for server 3',
241 description: 'my super description for server 3',
242 support: 'my super support text for server 3',
244 fixture: 'video_short3.webm'
246 await servers[2].videos.upload({ attributes })
251 name: 'my super name for server 3-2',
256 description: 'my super description for server 3-2',
257 support: 'my super support text for server 3-2',
258 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
259 fixture: 'video_short.webm'
261 await servers[2].videos.upload({ attributes })
264 await waitJobs(servers)
266 // All servers should have this video
267 for (const server of servers) {
268 const isLocal = server.url === 'http://localhost:' + servers[2].port
269 const { data } = await server.videos.list()
271 expect(data).to.be.an('array')
272 expect(data.length).to.equal(4)
274 // We not sure about the order of the two last uploads
277 if (data[2].name === 'my super name for server 3') {
285 const checkAttributesVideo1 = {
286 name: 'my super name for server 3',
291 description: 'my super description for server 3',
292 support: 'my super support text for server 3',
295 host: 'localhost:' + servers[2].port
299 commentsEnabled: true,
300 downloadEnabled: true,
302 privacy: VideoPrivacy.PUBLIC,
304 displayName: 'Main root channel',
305 name: 'root_channel',
309 fixture: 'video_short3.webm',
317 await completeVideoCheck(server, video1, checkAttributesVideo1)
319 const checkAttributesVideo2 = {
320 name: 'my super name for server 3-2',
325 description: 'my super description for server 3-2',
326 support: 'my super support text for server 3-2',
329 host: 'localhost:' + servers[2].port
331 commentsEnabled: true,
332 downloadEnabled: true,
335 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
336 privacy: VideoPrivacy.PUBLIC,
338 displayName: 'Main root channel',
339 name: 'root_channel',
343 fixture: 'video_short.webm',
351 await completeVideoCheck(server, video2, checkAttributesVideo2)
356 describe('It should list local videos', function () {
357 it('Should list only local videos on server 1', async function () {
358 const { data, total } = await servers[0].videos.list({ isLocal: true })
360 expect(total).to.equal(1)
361 expect(data).to.be.an('array')
362 expect(data.length).to.equal(1)
363 expect(data[0].name).to.equal('my super name for server 1')
366 it('Should list only local videos on server 2', async function () {
367 const { data, total } = await servers[1].videos.list({ isLocal: true })
369 expect(total).to.equal(1)
370 expect(data).to.be.an('array')
371 expect(data.length).to.equal(1)
372 expect(data[0].name).to.equal('my super name for server 2')
375 it('Should list only local videos on server 3', async function () {
376 const { data, total } = await servers[2].videos.list({ isLocal: true })
378 expect(total).to.equal(2)
379 expect(data).to.be.an('array')
380 expect(data.length).to.equal(2)
381 expect(data[0].name).to.equal('my super name for server 3')
382 expect(data[1].name).to.equal('my super name for server 3-2')
386 describe('Should seed the uploaded video', function () {
387 it('Should add the file 1 by asking server 3', async function () {
390 const { data } = await servers[2].videos.list()
392 const video = data[0]
393 toRemove.push(data[2])
394 toRemove.push(data[3])
396 const videoDetails = await servers[2].videos.get({ id: video.id })
397 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
398 expect(torrent.files).to.be.an('array')
399 expect(torrent.files.length).to.equal(1)
400 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
403 it('Should add the file 2 by asking server 1', async function () {
406 const { data } = await servers[0].videos.list()
408 const video = data[1]
409 const videoDetails = await servers[0].videos.get({ id: video.id })
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 3 by asking server 2', async function () {
420 const { data } = await servers[1].videos.list()
422 const video = data[2]
423 const videoDetails = await servers[1].videos.get({ id: video.id })
425 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
426 expect(torrent.files).to.be.an('array')
427 expect(torrent.files.length).to.equal(1)
428 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
431 it('Should add the file 3-2 by asking server 1', async function () {
434 const { data } = await servers[0].videos.list()
436 const video = data[3]
437 const videoDetails = await servers[0].videos.get({ id: video.id })
439 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
440 expect(torrent.files).to.be.an('array')
441 expect(torrent.files.length).to.equal(1)
442 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
445 it('Should add the file 2 in 360p by asking server 1', async function () {
448 const { data } = await servers[0].videos.list()
450 const video = data.find(v => v.name === 'my super name for server 2')
451 const videoDetails = await servers[0].videos.get({ id: video.id })
453 const file = videoDetails.files.find(f => f.resolution.id === 360)
454 expect(file).not.to.be.undefined
456 const torrent = await webtorrentAdd(file.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('')
463 describe('Should update video views, likes and dislikes', function () {
464 let localVideosServer3 = []
465 let remoteVideosServer1 = []
466 let remoteVideosServer2 = []
467 let remoteVideosServer3 = []
469 before(async function () {
471 const { data } = await servers[0].videos.list()
472 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
476 const { data } = await servers[1].videos.list()
477 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
481 const { data } = await servers[2].videos.list()
482 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
483 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
487 it('Should view multiple videos on owned servers', async function () {
490 await servers[2].videos.view({ id: localVideosServer3[0] })
493 await servers[2].videos.view({ id: localVideosServer3[0] })
494 await servers[2].videos.view({ id: localVideosServer3[1] })
498 await servers[2].videos.view({ id: localVideosServer3[0] })
499 await servers[2].videos.view({ id: localVideosServer3[0] })
501 await waitJobs(servers)
503 // Wait the repeatable job
506 await waitJobs(servers)
508 for (const server of servers) {
509 const { data } = await server.videos.list()
511 const video0 = data.find(v => v.uuid === localVideosServer3[0])
512 const video1 = data.find(v => v.uuid === localVideosServer3[1])
514 expect(video0.views).to.equal(3)
515 expect(video1.views).to.equal(1)
519 it('Should view multiple videos on each servers', async function () {
522 const tasks: Promise<any>[] = []
523 tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] }))
524 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
525 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
526 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] }))
527 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
528 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
529 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
530 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
531 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
532 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
534 await Promise.all(tasks)
536 await waitJobs(servers)
538 // Wait the repeatable job
541 await waitJobs(servers)
543 let baseVideos = null
545 for (const server of servers) {
546 const { data } = await server.videos.list()
548 // Initialize base videos for future comparisons
549 if (baseVideos === null) {
554 for (const baseVideo of baseVideos) {
555 const sameVideo = data.find(video => video.name === baseVideo.name)
556 expect(baseVideo.views).to.equal(sameVideo.views)
561 it('Should like and dislikes videos on different services', async function () {
564 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
566 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
568 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
569 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
571 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
572 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
574 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
576 await waitJobs(servers)
578 await waitJobs(servers)
580 let baseVideos = null
581 for (const server of servers) {
582 const { data } = await server.videos.list()
584 // Initialize base videos for future comparisons
585 if (baseVideos === null) {
590 for (const baseVideo of baseVideos) {
591 const sameVideo = data.find(video => video.name === baseVideo.name)
592 expect(baseVideo.likes).to.equal(sameVideo.likes)
593 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
599 describe('Should manipulate these videos', function () {
600 let updatedAtMin: Date
602 it('Should update video 3', async function () {
606 name: 'my super video updated',
611 description: 'my super description updated',
612 support: 'my super support text updated',
613 tags: [ 'tag_up_1', 'tag_up_2' ],
614 thumbnailfile: 'thumbnail.jpg',
615 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
616 previewfile: 'preview.jpg'
619 updatedAtMin = new Date()
620 await servers[2].videos.update({ id: toRemove[0].id, attributes })
622 await waitJobs(servers)
625 it('Should have the video 3 updated on each server', async function () {
628 for (const server of servers) {
629 const { data } = await server.videos.list()
631 const videoUpdated = data.find(video => video.name === 'my super video updated')
632 expect(!!videoUpdated).to.be.true
634 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
636 const isLocal = server.url === 'http://localhost:' + servers[2].port
637 const checkAttributes = {
638 name: 'my super video updated',
643 description: 'my super description updated',
644 support: 'my super support text updated',
645 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
648 host: 'localhost:' + servers[2].port
652 commentsEnabled: true,
653 downloadEnabled: true,
654 tags: [ 'tag_up_1', 'tag_up_2' ],
655 privacy: VideoPrivacy.PUBLIC,
657 displayName: 'Main root channel',
658 name: 'root_channel',
662 fixture: 'video_short3.webm',
669 thumbnailfile: 'thumbnail',
670 previewfile: 'preview'
672 await completeVideoCheck(server, videoUpdated, checkAttributes)
676 it('Should only update thumbnail and update updatedAt attribute', async function () {
680 thumbnailfile: 'thumbnail.jpg'
683 updatedAtMin = new Date()
684 await servers[2].videos.update({ id: toRemove[0].id, attributes })
686 await waitJobs(servers)
688 for (const server of servers) {
689 const { data } = await server.videos.list()
691 const videoUpdated = data.find(video => video.name === 'my super video updated')
692 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
696 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
699 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
700 await saveVideoInServers(servers, id)
702 await servers[2].videos.remove({ id })
704 await waitJobs(servers)
706 for (const server of servers) {
707 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
712 it('Should have videos 1 and 3 on each server', async function () {
713 for (const server of servers) {
714 const { data } = await server.videos.list()
716 expect(data).to.be.an('array')
717 expect(data.length).to.equal(2)
718 expect(data[0].name).not.to.equal(data[1].name)
719 expect(data[0].name).not.to.equal(toRemove[0].name)
720 expect(data[1].name).not.to.equal(toRemove[0].name)
721 expect(data[0].name).not.to.equal(toRemove[1].name)
722 expect(data[1].name).not.to.equal(toRemove[1].name)
724 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
728 it('Should get the same video by UUID on each server', async function () {
730 for (const server of servers) {
731 const video = await server.videos.get({ id: videoUUID })
733 if (baseVideo === null) {
738 expect(baseVideo.name).to.equal(video.name)
739 expect(baseVideo.uuid).to.equal(video.uuid)
740 expect(baseVideo.category.id).to.equal(video.category.id)
741 expect(baseVideo.language.id).to.equal(video.language.id)
742 expect(baseVideo.licence.id).to.equal(video.licence.id)
743 expect(baseVideo.nsfw).to.equal(video.nsfw)
744 expect(baseVideo.account.name).to.equal(video.account.name)
745 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
746 expect(baseVideo.account.url).to.equal(video.account.url)
747 expect(baseVideo.account.host).to.equal(video.account.host)
748 expect(baseVideo.tags).to.deep.equal(video.tags)
752 it('Should get the preview from each server', async function () {
753 for (const server of servers) {
754 const video = await server.videos.get({ id: videoUUID })
756 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
761 describe('Should comment these videos', function () {
762 let childOfFirstChild: VideoCommentThreadTree
764 it('Should add comment (threads and replies)', async function () {
768 const text = 'my super first comment'
769 await servers[0].comments.createThread({ videoId: videoUUID, text })
773 const text = 'my super second comment'
774 await servers[2].comments.createThread({ videoId: videoUUID, text })
777 await waitJobs(servers)
780 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
782 const text = 'my super answer to thread 1'
783 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
786 await waitJobs(servers)
789 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
791 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
792 const childCommentId = body.children[0].comment.id
794 const text3 = 'my second answer to thread 1'
795 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
797 const text2 = 'my super answer to answer of thread 1'
798 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
801 await waitJobs(servers)
804 it('Should have these threads', async function () {
805 for (const server of servers) {
806 const body = await server.comments.listThreads({ videoId: videoUUID })
808 expect(body.total).to.equal(2)
809 expect(body.data).to.be.an('array')
810 expect(body.data).to.have.lengthOf(2)
813 const comment = body.data.find(c => c.text === 'my super first 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[0].port)
818 expect(comment.totalReplies).to.equal(3)
819 expect(dateIsValid(comment.createdAt as string)).to.be.true
820 expect(dateIsValid(comment.updatedAt as string)).to.be.true
824 const comment = body.data.find(c => c.text === 'my super second comment')
825 expect(comment).to.not.be.undefined
826 expect(comment.inReplyToCommentId).to.be.null
827 expect(comment.account.name).to.equal('root')
828 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
829 expect(comment.totalReplies).to.equal(0)
830 expect(dateIsValid(comment.createdAt as string)).to.be.true
831 expect(dateIsValid(comment.updatedAt as string)).to.be.true
836 it('Should have these comments', async function () {
837 for (const server of servers) {
838 const body = await server.comments.listThreads({ videoId: videoUUID })
839 const threadId = body.data.find(c => c.text === 'my super first comment').id
841 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
843 expect(tree.comment.text).equal('my super first comment')
844 expect(tree.comment.account.name).equal('root')
845 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
846 expect(tree.children).to.have.lengthOf(2)
848 const firstChild = tree.children[0]
849 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
850 expect(firstChild.comment.account.name).equal('root')
851 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
852 expect(firstChild.children).to.have.lengthOf(1)
854 childOfFirstChild = firstChild.children[0]
855 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
856 expect(childOfFirstChild.comment.account.name).equal('root')
857 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
858 expect(childOfFirstChild.children).to.have.lengthOf(0)
860 const secondChild = tree.children[1]
861 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
862 expect(secondChild.comment.account.name).equal('root')
863 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
864 expect(secondChild.children).to.have.lengthOf(0)
868 it('Should delete a reply', async function () {
871 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
873 await waitJobs(servers)
876 it('Should have this comment marked as deleted', async function () {
877 for (const server of servers) {
878 const { data } = await server.comments.listThreads({ videoId: videoUUID })
879 const threadId = data.find(c => c.text === 'my super first comment').id
881 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
882 expect(tree.comment.text).equal('my super first comment')
884 const firstChild = tree.children[0]
885 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
886 expect(firstChild.children).to.have.lengthOf(1)
888 const deletedComment = firstChild.children[0].comment
889 expect(deletedComment.isDeleted).to.be.true
890 expect(deletedComment.deletedAt).to.not.be.null
891 expect(deletedComment.account).to.be.null
892 expect(deletedComment.text).to.equal('')
894 const secondChild = tree.children[1]
895 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
899 it('Should delete the thread comments', async function () {
902 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
903 const commentId = data.find(c => c.text === 'my super first comment').id
904 await servers[0].comments.delete({ videoId: videoUUID, commentId })
906 await waitJobs(servers)
909 it('Should have the threads marked as deleted on other servers too', async function () {
910 for (const server of servers) {
911 const body = await server.comments.listThreads({ videoId: videoUUID })
913 expect(body.total).to.equal(2)
914 expect(body.data).to.be.an('array')
915 expect(body.data).to.have.lengthOf(2)
918 const comment = body.data[0]
919 expect(comment).to.not.be.undefined
920 expect(comment.inReplyToCommentId).to.be.null
921 expect(comment.account.name).to.equal('root')
922 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
923 expect(comment.totalReplies).to.equal(0)
924 expect(dateIsValid(comment.createdAt as string)).to.be.true
925 expect(dateIsValid(comment.updatedAt as string)).to.be.true
929 const deletedComment = body.data[1]
930 expect(deletedComment).to.not.be.undefined
931 expect(deletedComment.isDeleted).to.be.true
932 expect(deletedComment.deletedAt).to.not.be.null
933 expect(deletedComment.text).to.equal('')
934 expect(deletedComment.inReplyToCommentId).to.be.null
935 expect(deletedComment.account).to.be.null
936 expect(deletedComment.totalReplies).to.equal(2)
937 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
938 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
939 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
944 it('Should delete a remote thread by the origin server', async function () {
947 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
948 const commentId = data.find(c => c.text === 'my super second comment').id
949 await servers[0].comments.delete({ videoId: videoUUID, commentId })
951 await waitJobs(servers)
954 it('Should have the threads marked as deleted on other servers too', async function () {
955 for (const server of servers) {
956 const body = await server.comments.listThreads({ videoId: videoUUID })
958 expect(body.total).to.equal(2)
959 expect(body.data).to.have.lengthOf(2)
962 const comment = body.data[0]
963 expect(comment.text).to.equal('')
964 expect(comment.isDeleted).to.be.true
965 expect(comment.createdAt).to.not.be.null
966 expect(comment.deletedAt).to.not.be.null
967 expect(comment.account).to.be.null
968 expect(comment.totalReplies).to.equal(0)
972 const comment = body.data[1]
973 expect(comment.text).to.equal('')
974 expect(comment.isDeleted).to.be.true
975 expect(comment.createdAt).to.not.be.null
976 expect(comment.deletedAt).to.not.be.null
977 expect(comment.account).to.be.null
978 expect(comment.totalReplies).to.equal(2)
983 it('Should disable comments and download', async function () {
987 commentsEnabled: false,
988 downloadEnabled: false
991 await servers[0].videos.update({ id: videoUUID, attributes })
993 await waitJobs(servers)
995 for (const server of servers) {
996 const video = await server.videos.get({ id: videoUUID })
997 expect(video.commentsEnabled).to.be.false
998 expect(video.downloadEnabled).to.be.false
1000 const text = 'my super forbidden comment'
1001 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
1006 describe('With minimum parameters', function () {
1007 it('Should upload and propagate the video', async function () {
1010 const path = '/api/v1/videos/upload'
1012 const req = request(servers[1].url)
1014 .set('Accept', 'application/json')
1015 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1016 .field('name', 'minimum parameters')
1017 .field('privacy', '1')
1018 .field('channelId', '1')
1020 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1021 .expect(HttpStatusCode.OK_200)
1023 await waitJobs(servers)
1025 for (const server of servers) {
1026 const { data } = await server.videos.list()
1027 const video = data.find(v => v.name === 'minimum parameters')
1029 const isLocal = server.url === 'http://localhost:' + servers[1].port
1030 const checkAttributes = {
1031 name: 'minimum parameters',
1040 host: 'localhost:' + servers[1].port
1044 commentsEnabled: true,
1045 downloadEnabled: true,
1047 privacy: VideoPrivacy.PUBLIC,
1049 displayName: 'Main root channel',
1050 name: 'root_channel',
1054 fixture: 'video_short.webm',
1074 await completeVideoCheck(server, video, checkAttributes)
1079 describe('TMP directory', function () {
1080 it('Should have an empty tmp directory', async function () {
1081 for (const server of servers) {
1082 await checkTmpIsEmpty(server)
1087 after(async function () {
1088 await cleanupTests(servers)