1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
4 import request from 'supertest'
7 checkVideoFilesWereRemoved,
13 } from '@server/tests/shared'
14 import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
15 import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
18 createMultipleServers,
22 setAccessTokensToServers,
23 setDefaultAccountAvatar,
24 setDefaultChannelAvatar,
26 } from '@shared/server-commands'
28 describe('Test multiple servers', function () {
29 let servers: PeerTubeServer[] = []
32 let videoChannelId: number
34 before(async function () {
37 servers = await createMultipleServers(3)
39 // Get the access tokens
40 await setAccessTokensToServers(servers)
43 const videoChannel = {
44 name: 'super_channel_name',
45 displayName: 'my channel',
46 description: 'super channel'
48 await servers[0].channels.create({ attributes: videoChannel })
49 await setDefaultChannelAvatar(servers[0], videoChannel.name)
50 await setDefaultAccountAvatar(servers)
52 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
53 videoChannelId = data[0].id
56 // Server 1 and server 2 follow each other
57 await doubleFollow(servers[0], servers[1])
58 // Server 1 and server 3 follow each other
59 await doubleFollow(servers[0], servers[2])
60 // Server 2 and server 3 follow each other
61 await doubleFollow(servers[1], servers[2])
64 it('Should not have videos for all servers', async function () {
65 for (const server of servers) {
66 const { data } = await server.videos.list()
67 expect(data).to.be.an('array')
68 expect(data.length).to.equal(0)
72 describe('Should upload the video and propagate on each server', function () {
73 it('Should upload the video on server 1 and propagate on each server', async function () {
77 name: 'my super name for server 1',
82 description: 'my super description for server 1',
83 support: 'my super support text for server 1',
84 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
85 tags: [ 'tag1p1', 'tag2p1' ],
86 channelId: videoChannelId,
87 fixture: 'video_short1.webm'
89 await servers[0].videos.upload({ attributes })
91 await waitJobs(servers)
93 // All servers should have this video
94 let publishedAt: string = null
95 for (const server of servers) {
96 const isLocal = server.port === servers[0].port
97 const checkAttributes = {
98 name: 'my super name for server 1',
103 description: 'my super description for server 1',
104 support: 'my super support text for server 1',
105 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
108 host: servers[0].host
113 tags: [ 'tag1p1', 'tag2p1' ],
114 privacy: VideoPrivacy.PUBLIC,
115 commentsEnabled: true,
116 downloadEnabled: true,
118 displayName: 'my channel',
119 name: 'super_channel_name',
120 description: 'super channel',
123 fixture: 'video_short1.webm',
132 const { data } = await server.videos.list()
133 expect(data).to.be.an('array')
134 expect(data.length).to.equal(1)
135 const video = data[0]
137 await completeVideoCheck({ server, originServer: servers[0], videoUUID: video.uuid, attributes: checkAttributes })
138 publishedAt = video.publishedAt as string
140 expect(video.channel.avatars).to.have.lengthOf(2)
141 expect(video.account.avatars).to.have.lengthOf(2)
143 for (const image of [ ...video.channel.avatars, ...video.account.avatars ]) {
144 expect(image.createdAt).to.exist
145 expect(image.updatedAt).to.exist
146 expect(image.width).to.be.above(20).and.below(1000)
147 expect(image.path).to.exist
149 await makeGetRequest({
152 expectedStatus: HttpStatusCode.OK_200
158 it('Should upload the video on server 2 and propagate on each server', async function () {
163 password: 'super_password'
165 await servers[1].users.create({ username: user.username, password: user.password })
166 const userAccessToken = await servers[1].login.getAccessToken(user)
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 servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
184 await waitJobs(servers)
186 // All servers should have this video
187 for (const server of servers) {
188 const isLocal = server.url === servers[1].url
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: servers[1].host
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 { data } = await server.videos.list()
237 expect(data).to.be.an('array')
238 expect(data.length).to.equal(2)
239 const video = data[1]
241 await completeVideoCheck({ server, originServer: servers[1], videoUUID: video.uuid, attributes: checkAttributes })
245 it('Should upload two videos on server 3 and propagate on each server', async function () {
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 servers[2].videos.upload({ attributes })
265 name: 'my super name for server 3-2',
270 description: 'my super description for server 3-2',
271 support: 'my super support text for server 3-2',
272 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
273 fixture: 'video_short.webm'
275 await servers[2].videos.upload({ attributes })
278 await waitJobs(servers)
280 // All servers should have this video
281 for (const server of servers) {
282 const isLocal = server.url === servers[2].url
283 const { data } = await server.videos.list()
285 expect(data).to.be.an('array')
286 expect(data.length).to.equal(4)
288 // We not sure about the order of the two last uploads
291 if (data[2].name === 'my super name for server 3') {
299 const checkAttributesVideo1 = {
300 name: 'my super name for server 3',
305 description: 'my super description for server 3',
306 support: 'my super support text for server 3',
309 host: servers[2].host
313 commentsEnabled: true,
314 downloadEnabled: true,
316 privacy: VideoPrivacy.PUBLIC,
318 displayName: 'Main root channel',
319 name: 'root_channel',
323 fixture: 'video_short3.webm',
331 await completeVideoCheck({ server, originServer: servers[2], videoUUID: video1.uuid, attributes: checkAttributesVideo1 })
333 const checkAttributesVideo2 = {
334 name: 'my super name for server 3-2',
339 description: 'my super description for server 3-2',
340 support: 'my super support text for server 3-2',
343 host: servers[2].host
345 commentsEnabled: true,
346 downloadEnabled: true,
349 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
350 privacy: VideoPrivacy.PUBLIC,
352 displayName: 'Main root channel',
353 name: 'root_channel',
357 fixture: 'video_short.webm',
365 await completeVideoCheck({ server, originServer: servers[2], videoUUID: video2.uuid, attributes: checkAttributesVideo2 })
370 describe('It should list local videos', function () {
371 it('Should list only local videos on server 1', async function () {
372 const { data, total } = await servers[0].videos.list({ isLocal: true })
374 expect(total).to.equal(1)
375 expect(data).to.be.an('array')
376 expect(data.length).to.equal(1)
377 expect(data[0].name).to.equal('my super name for server 1')
380 it('Should list only local videos on server 2', async function () {
381 const { data, total } = await servers[1].videos.list({ isLocal: true })
383 expect(total).to.equal(1)
384 expect(data).to.be.an('array')
385 expect(data.length).to.equal(1)
386 expect(data[0].name).to.equal('my super name for server 2')
389 it('Should list only local videos on server 3', async function () {
390 const { data, total } = await servers[2].videos.list({ isLocal: true })
392 expect(total).to.equal(2)
393 expect(data).to.be.an('array')
394 expect(data.length).to.equal(2)
395 expect(data[0].name).to.equal('my super name for server 3')
396 expect(data[1].name).to.equal('my super name for server 3-2')
400 describe('Should seed the uploaded video', function () {
401 it('Should add the file 1 by asking server 3', async function () {
404 const { data } = await servers[2].videos.list()
406 const video = data[0]
407 toRemove.push(data[2])
408 toRemove.push(data[3])
410 const videoDetails = await servers[2].videos.get({ id: video.id })
412 await checkWebTorrentWorks(videoDetails.files[0].magnetUri)
415 it('Should add the file 2 by asking server 1', async function () {
418 const { data } = await servers[0].videos.list()
420 const video = data[1]
421 const videoDetails = await servers[0].videos.get({ id: video.id })
423 await checkWebTorrentWorks(videoDetails.files[0].magnetUri)
426 it('Should add the file 3 by asking server 2', async function () {
429 const { data } = await servers[1].videos.list()
431 const video = data[2]
432 const videoDetails = await servers[1].videos.get({ id: video.id })
434 await checkWebTorrentWorks(videoDetails.files[0].magnetUri)
437 it('Should add the file 3-2 by asking server 1', async function () {
440 const { data } = await servers[0].videos.list()
442 const video = data[3]
443 const videoDetails = await servers[0].videos.get({ id: video.id })
445 await checkWebTorrentWorks(videoDetails.files[0].magnetUri)
448 it('Should add the file 2 in 360p by asking server 1', async function () {
451 const { data } = await servers[0].videos.list()
453 const video = data.find(v => v.name === 'my super name for server 2')
454 const videoDetails = await servers[0].videos.get({ id: video.id })
456 const file = videoDetails.files.find(f => f.resolution.id === 360)
457 expect(file).not.to.be.undefined
459 await checkWebTorrentWorks(file.magnetUri)
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].views.simulateView({ id: localVideosServer3[0] })
493 await servers[2].views.simulateView({ id: localVideosServer3[0] })
494 await servers[2].views.simulateView({ id: localVideosServer3[1] })
498 await servers[2].views.simulateView({ id: localVideosServer3[0] })
499 await servers[2].views.simulateView({ id: localVideosServer3[0] })
501 await waitJobs(servers)
503 for (const server of servers) {
504 await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } })
507 await waitJobs(servers)
509 for (const server of servers) {
510 const { data } = await server.videos.list()
512 const video0 = data.find(v => v.uuid === localVideosServer3[0])
513 const video1 = data.find(v => v.uuid === localVideosServer3[1])
515 expect(video0.views).to.equal(3)
516 expect(video1.views).to.equal(1)
520 it('Should view multiple videos on each servers', async function () {
523 const tasks: Promise<any>[] = []
524 tasks.push(servers[0].views.simulateView({ id: remoteVideosServer1[0] }))
525 tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] }))
526 tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] }))
527 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[0] }))
528 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
529 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
530 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
531 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
532 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
533 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
535 await Promise.all(tasks)
537 await waitJobs(servers)
539 for (const server of servers) {
540 await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } })
543 await waitJobs(servers)
545 let baseVideos = null
547 for (const server of servers) {
548 const { data } = await server.videos.list()
550 // Initialize base videos for future comparisons
551 if (baseVideos === null) {
556 for (const baseVideo of baseVideos) {
557 const sameVideo = data.find(video => video.name === baseVideo.name)
558 expect(baseVideo.views).to.equal(sameVideo.views)
563 it('Should like and dislikes videos on different services', async function () {
566 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
568 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
570 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
571 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
573 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
574 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
576 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
578 await waitJobs(servers)
580 await waitJobs(servers)
582 let baseVideos = null
583 for (const server of servers) {
584 const { data } = await server.videos.list()
586 // Initialize base videos for future comparisons
587 if (baseVideos === null) {
592 for (const baseVideo of baseVideos) {
593 const sameVideo = data.find(video => video.name === baseVideo.name)
594 expect(baseVideo.likes).to.equal(sameVideo.likes, `Likes of ${sameVideo.uuid} do not correspond`)
595 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes, `Dislikes of ${sameVideo.uuid} do not correspond`)
601 describe('Should manipulate these videos', function () {
602 let updatedAtMin: Date
604 it('Should update video 3', async function () {
608 name: 'my super video updated',
613 description: 'my super description updated',
614 support: 'my super support text updated',
615 tags: [ 'tag_up_1', 'tag_up_2' ],
616 thumbnailfile: 'thumbnail.jpg',
617 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
618 previewfile: 'preview.jpg'
621 updatedAtMin = new Date()
622 await servers[2].videos.update({ id: toRemove[0].id, attributes })
624 await waitJobs(servers)
627 it('Should have the video 3 updated on each server', async function () {
630 for (const server of servers) {
631 const { data } = await server.videos.list()
633 const videoUpdated = data.find(video => video.name === 'my super video updated')
634 expect(!!videoUpdated).to.be.true
636 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
638 const isLocal = server.url === servers[2].url
639 const checkAttributes = {
640 name: 'my super video updated',
645 description: 'my super description updated',
646 support: 'my super support text updated',
647 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
650 host: servers[2].host
654 commentsEnabled: true,
655 downloadEnabled: true,
656 tags: [ 'tag_up_1', 'tag_up_2' ],
657 privacy: VideoPrivacy.PUBLIC,
659 displayName: 'Main root channel',
660 name: 'root_channel',
664 fixture: 'video_short3.webm',
671 thumbnailfile: 'thumbnail',
672 previewfile: 'preview'
674 await completeVideoCheck({ server, originServer: servers[2], videoUUID: videoUpdated.uuid, attributes: checkAttributes })
678 it('Should only update thumbnail and update updatedAt attribute', async function () {
682 thumbnailfile: 'thumbnail.jpg'
685 updatedAtMin = new Date()
686 await servers[2].videos.update({ id: toRemove[0].id, attributes })
688 await waitJobs(servers)
690 for (const server of servers) {
691 const { data } = await server.videos.list()
693 const videoUpdated = data.find(video => video.name === 'my super video updated')
694 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
698 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
701 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
702 await saveVideoInServers(servers, id)
704 await servers[2].videos.remove({ id })
706 await waitJobs(servers)
708 for (const server of servers) {
709 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
714 it('Should have videos 1 and 3 on each server', async function () {
715 for (const server of servers) {
716 const { data } = await server.videos.list()
718 expect(data).to.be.an('array')
719 expect(data.length).to.equal(2)
720 expect(data[0].name).not.to.equal(data[1].name)
721 expect(data[0].name).not.to.equal(toRemove[0].name)
722 expect(data[1].name).not.to.equal(toRemove[0].name)
723 expect(data[0].name).not.to.equal(toRemove[1].name)
724 expect(data[1].name).not.to.equal(toRemove[1].name)
726 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
730 it('Should get the same video by UUID on each server', async function () {
732 for (const server of servers) {
733 const video = await server.videos.get({ id: videoUUID })
735 if (baseVideo === null) {
740 expect(baseVideo.name).to.equal(video.name)
741 expect(baseVideo.uuid).to.equal(video.uuid)
742 expect(baseVideo.category.id).to.equal(video.category.id)
743 expect(baseVideo.language.id).to.equal(video.language.id)
744 expect(baseVideo.licence.id).to.equal(video.licence.id)
745 expect(baseVideo.nsfw).to.equal(video.nsfw)
746 expect(baseVideo.account.name).to.equal(video.account.name)
747 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
748 expect(baseVideo.account.url).to.equal(video.account.url)
749 expect(baseVideo.account.host).to.equal(video.account.host)
750 expect(baseVideo.tags).to.deep.equal(video.tags)
754 it('Should get the preview from each server', async function () {
755 for (const server of servers) {
756 const video = await server.videos.get({ id: videoUUID })
758 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
763 describe('Should comment these videos', function () {
764 let childOfFirstChild: VideoCommentThreadTree
766 it('Should add comment (threads and replies)', async function () {
770 const text = 'my super first comment'
771 await servers[0].comments.createThread({ videoId: videoUUID, text })
775 const text = 'my super second comment'
776 await servers[2].comments.createThread({ videoId: videoUUID, text })
779 await waitJobs(servers)
782 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
784 const text = 'my super answer to thread 1'
785 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
788 await waitJobs(servers)
791 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
793 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
794 const childCommentId = body.children[0].comment.id
796 const text3 = 'my second answer to thread 1'
797 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
799 const text2 = 'my super answer to answer of thread 1'
800 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
803 await waitJobs(servers)
806 it('Should have these threads', async function () {
807 for (const server of servers) {
808 const body = await server.comments.listThreads({ videoId: videoUUID })
810 expect(body.total).to.equal(2)
811 expect(body.data).to.be.an('array')
812 expect(body.data).to.have.lengthOf(2)
815 const comment = body.data.find(c => c.text === 'my super first comment')
816 expect(comment).to.not.be.undefined
817 expect(comment.inReplyToCommentId).to.be.null
818 expect(comment.account.name).to.equal('root')
819 expect(comment.account.host).to.equal(servers[0].host)
820 expect(comment.totalReplies).to.equal(3)
821 expect(dateIsValid(comment.createdAt as string)).to.be.true
822 expect(dateIsValid(comment.updatedAt as string)).to.be.true
826 const comment = body.data.find(c => c.text === 'my super second comment')
827 expect(comment).to.not.be.undefined
828 expect(comment.inReplyToCommentId).to.be.null
829 expect(comment.account.name).to.equal('root')
830 expect(comment.account.host).to.equal(servers[2].host)
831 expect(comment.totalReplies).to.equal(0)
832 expect(dateIsValid(comment.createdAt as string)).to.be.true
833 expect(dateIsValid(comment.updatedAt as string)).to.be.true
838 it('Should have these comments', async function () {
839 for (const server of servers) {
840 const body = await server.comments.listThreads({ videoId: videoUUID })
841 const threadId = body.data.find(c => c.text === 'my super first comment').id
843 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
845 expect(tree.comment.text).equal('my super first comment')
846 expect(tree.comment.account.name).equal('root')
847 expect(tree.comment.account.host).equal(servers[0].host)
848 expect(tree.children).to.have.lengthOf(2)
850 const firstChild = tree.children[0]
851 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
852 expect(firstChild.comment.account.name).equal('root')
853 expect(firstChild.comment.account.host).equal(servers[1].host)
854 expect(firstChild.children).to.have.lengthOf(1)
856 childOfFirstChild = firstChild.children[0]
857 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
858 expect(childOfFirstChild.comment.account.name).equal('root')
859 expect(childOfFirstChild.comment.account.host).equal(servers[2].host)
860 expect(childOfFirstChild.children).to.have.lengthOf(0)
862 const secondChild = tree.children[1]
863 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
864 expect(secondChild.comment.account.name).equal('root')
865 expect(secondChild.comment.account.host).equal(servers[2].host)
866 expect(secondChild.children).to.have.lengthOf(0)
870 it('Should delete a reply', async function () {
873 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
875 await waitJobs(servers)
878 it('Should have this comment marked as deleted', async function () {
879 for (const server of servers) {
880 const { data } = await server.comments.listThreads({ videoId: videoUUID })
881 const threadId = data.find(c => c.text === 'my super first comment').id
883 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
884 expect(tree.comment.text).equal('my super first comment')
886 const firstChild = tree.children[0]
887 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
888 expect(firstChild.children).to.have.lengthOf(1)
890 const deletedComment = firstChild.children[0].comment
891 expect(deletedComment.isDeleted).to.be.true
892 expect(deletedComment.deletedAt).to.not.be.null
893 expect(deletedComment.account).to.be.null
894 expect(deletedComment.text).to.equal('')
896 const secondChild = tree.children[1]
897 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
901 it('Should delete the thread comments', async function () {
904 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
905 const commentId = data.find(c => c.text === 'my super first comment').id
906 await servers[0].comments.delete({ videoId: videoUUID, commentId })
908 await waitJobs(servers)
911 it('Should have the threads marked as deleted on other servers too', async function () {
912 for (const server of servers) {
913 const body = await server.comments.listThreads({ videoId: videoUUID })
915 expect(body.total).to.equal(2)
916 expect(body.data).to.be.an('array')
917 expect(body.data).to.have.lengthOf(2)
920 const comment = body.data[0]
921 expect(comment).to.not.be.undefined
922 expect(comment.inReplyToCommentId).to.be.null
923 expect(comment.account.name).to.equal('root')
924 expect(comment.account.host).to.equal(servers[2].host)
925 expect(comment.totalReplies).to.equal(0)
926 expect(dateIsValid(comment.createdAt as string)).to.be.true
927 expect(dateIsValid(comment.updatedAt as string)).to.be.true
931 const deletedComment = body.data[1]
932 expect(deletedComment).to.not.be.undefined
933 expect(deletedComment.isDeleted).to.be.true
934 expect(deletedComment.deletedAt).to.not.be.null
935 expect(deletedComment.text).to.equal('')
936 expect(deletedComment.inReplyToCommentId).to.be.null
937 expect(deletedComment.account).to.be.null
938 expect(deletedComment.totalReplies).to.equal(2)
939 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
940 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
941 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
946 it('Should delete a remote thread by the origin server', async function () {
949 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
950 const commentId = data.find(c => c.text === 'my super second comment').id
951 await servers[0].comments.delete({ videoId: videoUUID, commentId })
953 await waitJobs(servers)
956 it('Should have the threads marked as deleted on other servers too', async function () {
957 for (const server of servers) {
958 const body = await server.comments.listThreads({ videoId: videoUUID })
960 expect(body.total).to.equal(2)
961 expect(body.data).to.have.lengthOf(2)
964 const comment = body.data[0]
965 expect(comment.text).to.equal('')
966 expect(comment.isDeleted).to.be.true
967 expect(comment.createdAt).to.not.be.null
968 expect(comment.deletedAt).to.not.be.null
969 expect(comment.account).to.be.null
970 expect(comment.totalReplies).to.equal(0)
974 const comment = body.data[1]
975 expect(comment.text).to.equal('')
976 expect(comment.isDeleted).to.be.true
977 expect(comment.createdAt).to.not.be.null
978 expect(comment.deletedAt).to.not.be.null
979 expect(comment.account).to.be.null
980 expect(comment.totalReplies).to.equal(2)
985 it('Should disable comments and download', async function () {
989 commentsEnabled: false,
990 downloadEnabled: false
993 await servers[0].videos.update({ id: videoUUID, attributes })
995 await waitJobs(servers)
997 for (const server of servers) {
998 const video = await server.videos.get({ id: videoUUID })
999 expect(video.commentsEnabled).to.be.false
1000 expect(video.downloadEnabled).to.be.false
1002 const text = 'my super forbidden comment'
1003 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
1008 describe('With minimum parameters', function () {
1009 it('Should upload and propagate the video', async function () {
1010 this.timeout(120000)
1012 const path = '/api/v1/videos/upload'
1014 const req = request(servers[1].url)
1016 .set('Accept', 'application/json')
1017 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1018 .field('name', 'minimum parameters')
1019 .field('privacy', '1')
1020 .field('channelId', '1')
1022 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1023 .expect(HttpStatusCode.OK_200)
1025 await waitJobs(servers)
1027 for (const server of servers) {
1028 const { data } = await server.videos.list()
1029 const video = data.find(v => v.name === 'minimum parameters')
1031 const isLocal = server.url === servers[1].url
1032 const checkAttributes = {
1033 name: 'minimum parameters',
1042 host: servers[1].host
1046 commentsEnabled: true,
1047 downloadEnabled: true,
1049 privacy: VideoPrivacy.PUBLIC,
1051 displayName: 'Main root channel',
1052 name: 'root_channel',
1056 fixture: 'video_short.webm',
1076 await completeVideoCheck({ server, originServer: servers[1], videoUUID: video.uuid, attributes: checkAttributes })
1081 describe('TMP directory', function () {
1082 it('Should have an empty tmp directory', async function () {
1083 for (const server of servers) {
1084 await checkTmpIsEmpty(server)
1089 after(async function () {
1090 await cleanupTests(servers)