1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { and } from 'sequelize/dist'
6 import request from 'supertest'
9 checkVideoFilesWereRemoved,
14 } from '@server/tests/shared'
15 import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
16 import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
19 createMultipleServers,
23 setAccessTokensToServers,
24 setDefaultAccountAvatar,
25 setDefaultChannelAvatar,
28 } from '@shared/server-commands'
30 const expect = chai.expect
32 describe('Test multiple servers', function () {
33 let servers: PeerTubeServer[] = []
36 let videoChannelId: number
38 before(async function () {
41 servers = await createMultipleServers(3)
43 // Get the access tokens
44 await setAccessTokensToServers(servers)
47 const videoChannel = {
48 name: 'super_channel_name',
49 displayName: 'my channel',
50 description: 'super channel'
52 await servers[0].channels.create({ attributes: videoChannel })
53 await setDefaultChannelAvatar(servers[0], videoChannel.name)
54 await setDefaultAccountAvatar(servers)
56 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
57 videoChannelId = data[0].id
60 // Server 1 and server 2 follow each other
61 await doubleFollow(servers[0], servers[1])
62 // Server 1 and server 3 follow each other
63 await doubleFollow(servers[0], servers[2])
64 // Server 2 and server 3 follow each other
65 await doubleFollow(servers[1], servers[2])
68 it('Should not have videos for all servers', async function () {
69 for (const server of servers) {
70 const { data } = await server.videos.list()
71 expect(data).to.be.an('array')
72 expect(data.length).to.equal(0)
76 describe('Should upload the video and propagate on each server', function () {
77 it('Should upload the video on server 1 and propagate on each server', async function () {
81 name: 'my super name for server 1',
86 description: 'my super description for server 1',
87 support: 'my super support text for server 1',
88 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
89 tags: [ 'tag1p1', 'tag2p1' ],
90 channelId: videoChannelId,
91 fixture: 'video_short1.webm'
93 await servers[0].videos.upload({ attributes })
95 await waitJobs(servers)
97 // All servers should have this video
98 let publishedAt: string = null
99 for (const server of servers) {
100 const isLocal = server.port === servers[0].port
101 const checkAttributes = {
102 name: 'my super name for server 1',
107 description: 'my super description for server 1',
108 support: 'my super support text for server 1',
109 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
112 host: 'localhost:' + servers[0].port
117 tags: [ 'tag1p1', 'tag2p1' ],
118 privacy: VideoPrivacy.PUBLIC,
119 commentsEnabled: true,
120 downloadEnabled: true,
122 displayName: 'my channel',
123 name: 'super_channel_name',
124 description: 'super channel',
127 fixture: 'video_short1.webm',
136 const { data } = await server.videos.list()
137 expect(data).to.be.an('array')
138 expect(data.length).to.equal(1)
139 const video = data[0]
141 await completeVideoCheck(server, video, checkAttributes)
142 publishedAt = video.publishedAt as string
144 expect(video.channel.avatars).to.have.lengthOf(2)
145 expect(video.account.avatars).to.have.lengthOf(2)
147 for (const image of [ ...video.channel.avatars, ...video.account.avatars ]) {
148 expect(image.createdAt).to.exist
149 expect(image.updatedAt).to.exist
150 expect(image.width).to.be.above(20).and.below(1000)
151 expect(image.path).to.exist
153 await makeGetRequest({
156 expectedStatus: HttpStatusCode.OK_200
162 it('Should upload the video on server 2 and propagate on each server', async function () {
167 password: 'super_password'
169 await servers[1].users.create({ username: user.username, password: user.password })
170 const userAccessToken = await servers[1].login.getAccessToken(user)
173 name: 'my super name for server 2',
178 description: 'my super description for server 2',
179 support: 'my super support text for server 2',
180 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
181 fixture: 'video_short2.webm',
182 thumbnailfile: 'thumbnail.jpg',
183 previewfile: 'preview.jpg'
185 await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
188 await waitJobs(servers)
190 // All servers should have this video
191 for (const server of servers) {
192 const isLocal = server.url === 'http://localhost:' + servers[1].port
193 const checkAttributes = {
194 name: 'my super name for server 2',
199 description: 'my super description for server 2',
200 support: 'my super support text for server 2',
203 host: 'localhost:' + servers[1].port
206 commentsEnabled: true,
207 downloadEnabled: true,
209 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
210 privacy: VideoPrivacy.PUBLIC,
212 displayName: 'Main user1 channel',
213 name: 'user1_channel',
214 description: 'super channel',
217 fixture: 'video_short2.webm',
236 thumbnailfile: 'thumbnail',
237 previewfile: 'preview'
240 const { data } = await server.videos.list()
241 expect(data).to.be.an('array')
242 expect(data.length).to.equal(2)
243 const video = data[1]
245 await completeVideoCheck(server, video, checkAttributes)
249 it('Should upload two videos on server 3 and propagate on each server', async function () {
254 name: 'my super name for server 3',
259 description: 'my super description for server 3',
260 support: 'my super support text for server 3',
262 fixture: 'video_short3.webm'
264 await servers[2].videos.upload({ attributes })
269 name: 'my super name for server 3-2',
274 description: 'my super description for server 3-2',
275 support: 'my super support text for server 3-2',
276 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
277 fixture: 'video_short.webm'
279 await servers[2].videos.upload({ attributes })
282 await waitJobs(servers)
284 // All servers should have this video
285 for (const server of servers) {
286 const isLocal = server.url === 'http://localhost:' + servers[2].port
287 const { data } = await server.videos.list()
289 expect(data).to.be.an('array')
290 expect(data.length).to.equal(4)
292 // We not sure about the order of the two last uploads
295 if (data[2].name === 'my super name for server 3') {
303 const checkAttributesVideo1 = {
304 name: 'my super name for server 3',
309 description: 'my super description for server 3',
310 support: 'my super support text for server 3',
313 host: 'localhost:' + servers[2].port
317 commentsEnabled: true,
318 downloadEnabled: true,
320 privacy: VideoPrivacy.PUBLIC,
322 displayName: 'Main root channel',
323 name: 'root_channel',
327 fixture: 'video_short3.webm',
335 await completeVideoCheck(server, video1, checkAttributesVideo1)
337 const checkAttributesVideo2 = {
338 name: 'my super name for server 3-2',
343 description: 'my super description for server 3-2',
344 support: 'my super support text for server 3-2',
347 host: 'localhost:' + servers[2].port
349 commentsEnabled: true,
350 downloadEnabled: true,
353 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
354 privacy: VideoPrivacy.PUBLIC,
356 displayName: 'Main root channel',
357 name: 'root_channel',
361 fixture: 'video_short.webm',
369 await completeVideoCheck(server, video2, checkAttributesVideo2)
374 describe('It should list local videos', function () {
375 it('Should list only local videos on server 1', async function () {
376 const { data, total } = await servers[0].videos.list({ isLocal: true })
378 expect(total).to.equal(1)
379 expect(data).to.be.an('array')
380 expect(data.length).to.equal(1)
381 expect(data[0].name).to.equal('my super name for server 1')
384 it('Should list only local videos on server 2', async function () {
385 const { data, total } = await servers[1].videos.list({ isLocal: true })
387 expect(total).to.equal(1)
388 expect(data).to.be.an('array')
389 expect(data.length).to.equal(1)
390 expect(data[0].name).to.equal('my super name for server 2')
393 it('Should list only local videos on server 3', async function () {
394 const { data, total } = await servers[2].videos.list({ isLocal: true })
396 expect(total).to.equal(2)
397 expect(data).to.be.an('array')
398 expect(data.length).to.equal(2)
399 expect(data[0].name).to.equal('my super name for server 3')
400 expect(data[1].name).to.equal('my super name for server 3-2')
404 describe('Should seed the uploaded video', function () {
405 it('Should add the file 1 by asking server 3', async function () {
408 const { data } = await servers[2].videos.list()
410 const video = data[0]
411 toRemove.push(data[2])
412 toRemove.push(data[3])
414 const videoDetails = await servers[2].videos.get({ id: video.id })
415 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
416 expect(torrent.files).to.be.an('array')
417 expect(torrent.files.length).to.equal(1)
418 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
421 it('Should add the file 2 by asking server 1', async function () {
424 const { data } = await servers[0].videos.list()
426 const video = data[1]
427 const videoDetails = await servers[0].videos.get({ id: video.id })
429 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
430 expect(torrent.files).to.be.an('array')
431 expect(torrent.files.length).to.equal(1)
432 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
435 it('Should add the file 3 by asking server 2', async function () {
438 const { data } = await servers[1].videos.list()
440 const video = data[2]
441 const videoDetails = await servers[1].videos.get({ id: video.id })
443 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
444 expect(torrent.files).to.be.an('array')
445 expect(torrent.files.length).to.equal(1)
446 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
449 it('Should add the file 3-2 by asking server 1', async function () {
452 const { data } = await servers[0].videos.list()
454 const video = data[3]
455 const videoDetails = await servers[0].videos.get({ id: video.id })
457 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
458 expect(torrent.files).to.be.an('array')
459 expect(torrent.files.length).to.equal(1)
460 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
463 it('Should add the file 2 in 360p by asking server 1', async function () {
466 const { data } = await servers[0].videos.list()
468 const video = data.find(v => v.name === 'my super name for server 2')
469 const videoDetails = await servers[0].videos.get({ id: video.id })
471 const file = videoDetails.files.find(f => f.resolution.id === 360)
472 expect(file).not.to.be.undefined
474 const torrent = await webtorrentAdd(file.magnetUri)
475 expect(torrent.files).to.be.an('array')
476 expect(torrent.files.length).to.equal(1)
477 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
481 describe('Should update video views, likes and dislikes', function () {
482 let localVideosServer3 = []
483 let remoteVideosServer1 = []
484 let remoteVideosServer2 = []
485 let remoteVideosServer3 = []
487 before(async function () {
489 const { data } = await servers[0].videos.list()
490 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
494 const { data } = await servers[1].videos.list()
495 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
499 const { data } = await servers[2].videos.list()
500 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
501 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
505 it('Should view multiple videos on owned servers', async function () {
508 await servers[2].videos.view({ id: localVideosServer3[0] })
511 await servers[2].videos.view({ id: localVideosServer3[0] })
512 await servers[2].videos.view({ id: localVideosServer3[1] })
516 await servers[2].videos.view({ id: localVideosServer3[0] })
517 await servers[2].videos.view({ id: localVideosServer3[0] })
519 await waitJobs(servers)
521 // Wait the repeatable job
524 await waitJobs(servers)
526 for (const server of servers) {
527 const { data } = await server.videos.list()
529 const video0 = data.find(v => v.uuid === localVideosServer3[0])
530 const video1 = data.find(v => v.uuid === localVideosServer3[1])
532 expect(video0.views).to.equal(3)
533 expect(video1.views).to.equal(1)
537 it('Should view multiple videos on each servers', async function () {
540 const tasks: Promise<any>[] = []
541 tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] }))
542 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
543 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
544 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] }))
545 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
546 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
547 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
548 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
549 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
550 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
552 await Promise.all(tasks)
554 await waitJobs(servers)
556 // Wait the repeatable job
559 await waitJobs(servers)
561 let baseVideos = null
563 for (const server of servers) {
564 const { data } = await server.videos.list()
566 // Initialize base videos for future comparisons
567 if (baseVideos === null) {
572 for (const baseVideo of baseVideos) {
573 const sameVideo = data.find(video => video.name === baseVideo.name)
574 expect(baseVideo.views).to.equal(sameVideo.views)
579 it('Should like and dislikes videos on different services', async function () {
582 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
584 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
586 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
587 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
589 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
590 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
592 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
594 await waitJobs(servers)
596 await waitJobs(servers)
598 let baseVideos = null
599 for (const server of servers) {
600 const { data } = await server.videos.list()
602 // Initialize base videos for future comparisons
603 if (baseVideos === null) {
608 for (const baseVideo of baseVideos) {
609 const sameVideo = data.find(video => video.name === baseVideo.name)
610 expect(baseVideo.likes).to.equal(sameVideo.likes)
611 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
617 describe('Should manipulate these videos', function () {
618 let updatedAtMin: Date
620 it('Should update video 3', async function () {
624 name: 'my super video updated',
629 description: 'my super description updated',
630 support: 'my super support text updated',
631 tags: [ 'tag_up_1', 'tag_up_2' ],
632 thumbnailfile: 'thumbnail.jpg',
633 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
634 previewfile: 'preview.jpg'
637 updatedAtMin = new Date()
638 await servers[2].videos.update({ id: toRemove[0].id, attributes })
640 await waitJobs(servers)
643 it('Should have the video 3 updated on each server', async function () {
646 for (const server of servers) {
647 const { data } = await server.videos.list()
649 const videoUpdated = data.find(video => video.name === 'my super video updated')
650 expect(!!videoUpdated).to.be.true
652 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
654 const isLocal = server.url === 'http://localhost:' + servers[2].port
655 const checkAttributes = {
656 name: 'my super video updated',
661 description: 'my super description updated',
662 support: 'my super support text updated',
663 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
666 host: 'localhost:' + servers[2].port
670 commentsEnabled: true,
671 downloadEnabled: true,
672 tags: [ 'tag_up_1', 'tag_up_2' ],
673 privacy: VideoPrivacy.PUBLIC,
675 displayName: 'Main root channel',
676 name: 'root_channel',
680 fixture: 'video_short3.webm',
687 thumbnailfile: 'thumbnail',
688 previewfile: 'preview'
690 await completeVideoCheck(server, videoUpdated, checkAttributes)
694 it('Should only update thumbnail and update updatedAt attribute', async function () {
698 thumbnailfile: 'thumbnail.jpg'
701 updatedAtMin = new Date()
702 await servers[2].videos.update({ id: toRemove[0].id, attributes })
704 await waitJobs(servers)
706 for (const server of servers) {
707 const { data } = await server.videos.list()
709 const videoUpdated = data.find(video => video.name === 'my super video updated')
710 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
714 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
717 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
718 await saveVideoInServers(servers, id)
720 await servers[2].videos.remove({ id })
722 await waitJobs(servers)
724 for (const server of servers) {
725 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
730 it('Should have videos 1 and 3 on each server', async function () {
731 for (const server of servers) {
732 const { data } = await server.videos.list()
734 expect(data).to.be.an('array')
735 expect(data.length).to.equal(2)
736 expect(data[0].name).not.to.equal(data[1].name)
737 expect(data[0].name).not.to.equal(toRemove[0].name)
738 expect(data[1].name).not.to.equal(toRemove[0].name)
739 expect(data[0].name).not.to.equal(toRemove[1].name)
740 expect(data[1].name).not.to.equal(toRemove[1].name)
742 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
746 it('Should get the same video by UUID on each server', async function () {
748 for (const server of servers) {
749 const video = await server.videos.get({ id: videoUUID })
751 if (baseVideo === null) {
756 expect(baseVideo.name).to.equal(video.name)
757 expect(baseVideo.uuid).to.equal(video.uuid)
758 expect(baseVideo.category.id).to.equal(video.category.id)
759 expect(baseVideo.language.id).to.equal(video.language.id)
760 expect(baseVideo.licence.id).to.equal(video.licence.id)
761 expect(baseVideo.nsfw).to.equal(video.nsfw)
762 expect(baseVideo.account.name).to.equal(video.account.name)
763 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
764 expect(baseVideo.account.url).to.equal(video.account.url)
765 expect(baseVideo.account.host).to.equal(video.account.host)
766 expect(baseVideo.tags).to.deep.equal(video.tags)
770 it('Should get the preview from each server', async function () {
771 for (const server of servers) {
772 const video = await server.videos.get({ id: videoUUID })
774 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
779 describe('Should comment these videos', function () {
780 let childOfFirstChild: VideoCommentThreadTree
782 it('Should add comment (threads and replies)', async function () {
786 const text = 'my super first comment'
787 await servers[0].comments.createThread({ videoId: videoUUID, text })
791 const text = 'my super second comment'
792 await servers[2].comments.createThread({ videoId: videoUUID, text })
795 await waitJobs(servers)
798 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
800 const text = 'my super answer to thread 1'
801 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
804 await waitJobs(servers)
807 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
809 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
810 const childCommentId = body.children[0].comment.id
812 const text3 = 'my second answer to thread 1'
813 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
815 const text2 = 'my super answer to answer of thread 1'
816 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
819 await waitJobs(servers)
822 it('Should have these threads', async function () {
823 for (const server of servers) {
824 const body = await server.comments.listThreads({ videoId: videoUUID })
826 expect(body.total).to.equal(2)
827 expect(body.data).to.be.an('array')
828 expect(body.data).to.have.lengthOf(2)
831 const comment = body.data.find(c => c.text === 'my super first comment')
832 expect(comment).to.not.be.undefined
833 expect(comment.inReplyToCommentId).to.be.null
834 expect(comment.account.name).to.equal('root')
835 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
836 expect(comment.totalReplies).to.equal(3)
837 expect(dateIsValid(comment.createdAt as string)).to.be.true
838 expect(dateIsValid(comment.updatedAt as string)).to.be.true
842 const comment = body.data.find(c => c.text === 'my super second comment')
843 expect(comment).to.not.be.undefined
844 expect(comment.inReplyToCommentId).to.be.null
845 expect(comment.account.name).to.equal('root')
846 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
847 expect(comment.totalReplies).to.equal(0)
848 expect(dateIsValid(comment.createdAt as string)).to.be.true
849 expect(dateIsValid(comment.updatedAt as string)).to.be.true
854 it('Should have these comments', async function () {
855 for (const server of servers) {
856 const body = await server.comments.listThreads({ videoId: videoUUID })
857 const threadId = body.data.find(c => c.text === 'my super first comment').id
859 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
861 expect(tree.comment.text).equal('my super first comment')
862 expect(tree.comment.account.name).equal('root')
863 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
864 expect(tree.children).to.have.lengthOf(2)
866 const firstChild = tree.children[0]
867 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
868 expect(firstChild.comment.account.name).equal('root')
869 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
870 expect(firstChild.children).to.have.lengthOf(1)
872 childOfFirstChild = firstChild.children[0]
873 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
874 expect(childOfFirstChild.comment.account.name).equal('root')
875 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
876 expect(childOfFirstChild.children).to.have.lengthOf(0)
878 const secondChild = tree.children[1]
879 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
880 expect(secondChild.comment.account.name).equal('root')
881 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
882 expect(secondChild.children).to.have.lengthOf(0)
886 it('Should delete a reply', async function () {
889 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
891 await waitJobs(servers)
894 it('Should have this comment marked as deleted', async function () {
895 for (const server of servers) {
896 const { data } = await server.comments.listThreads({ videoId: videoUUID })
897 const threadId = data.find(c => c.text === 'my super first comment').id
899 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
900 expect(tree.comment.text).equal('my super first comment')
902 const firstChild = tree.children[0]
903 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
904 expect(firstChild.children).to.have.lengthOf(1)
906 const deletedComment = firstChild.children[0].comment
907 expect(deletedComment.isDeleted).to.be.true
908 expect(deletedComment.deletedAt).to.not.be.null
909 expect(deletedComment.account).to.be.null
910 expect(deletedComment.text).to.equal('')
912 const secondChild = tree.children[1]
913 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
917 it('Should delete the thread comments', async function () {
920 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
921 const commentId = data.find(c => c.text === 'my super first comment').id
922 await servers[0].comments.delete({ videoId: videoUUID, commentId })
924 await waitJobs(servers)
927 it('Should have the threads marked as deleted on other servers too', async function () {
928 for (const server of servers) {
929 const body = await server.comments.listThreads({ videoId: videoUUID })
931 expect(body.total).to.equal(2)
932 expect(body.data).to.be.an('array')
933 expect(body.data).to.have.lengthOf(2)
936 const comment = body.data[0]
937 expect(comment).to.not.be.undefined
938 expect(comment.inReplyToCommentId).to.be.null
939 expect(comment.account.name).to.equal('root')
940 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
941 expect(comment.totalReplies).to.equal(0)
942 expect(dateIsValid(comment.createdAt as string)).to.be.true
943 expect(dateIsValid(comment.updatedAt as string)).to.be.true
947 const deletedComment = body.data[1]
948 expect(deletedComment).to.not.be.undefined
949 expect(deletedComment.isDeleted).to.be.true
950 expect(deletedComment.deletedAt).to.not.be.null
951 expect(deletedComment.text).to.equal('')
952 expect(deletedComment.inReplyToCommentId).to.be.null
953 expect(deletedComment.account).to.be.null
954 expect(deletedComment.totalReplies).to.equal(2)
955 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
956 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
957 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
962 it('Should delete a remote thread by the origin server', async function () {
965 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
966 const commentId = data.find(c => c.text === 'my super second comment').id
967 await servers[0].comments.delete({ videoId: videoUUID, commentId })
969 await waitJobs(servers)
972 it('Should have the threads marked as deleted on other servers too', async function () {
973 for (const server of servers) {
974 const body = await server.comments.listThreads({ videoId: videoUUID })
976 expect(body.total).to.equal(2)
977 expect(body.data).to.have.lengthOf(2)
980 const comment = body.data[0]
981 expect(comment.text).to.equal('')
982 expect(comment.isDeleted).to.be.true
983 expect(comment.createdAt).to.not.be.null
984 expect(comment.deletedAt).to.not.be.null
985 expect(comment.account).to.be.null
986 expect(comment.totalReplies).to.equal(0)
990 const comment = body.data[1]
991 expect(comment.text).to.equal('')
992 expect(comment.isDeleted).to.be.true
993 expect(comment.createdAt).to.not.be.null
994 expect(comment.deletedAt).to.not.be.null
995 expect(comment.account).to.be.null
996 expect(comment.totalReplies).to.equal(2)
1001 it('Should disable comments and download', async function () {
1004 const attributes = {
1005 commentsEnabled: false,
1006 downloadEnabled: false
1009 await servers[0].videos.update({ id: videoUUID, attributes })
1011 await waitJobs(servers)
1013 for (const server of servers) {
1014 const video = await server.videos.get({ id: videoUUID })
1015 expect(video.commentsEnabled).to.be.false
1016 expect(video.downloadEnabled).to.be.false
1018 const text = 'my super forbidden comment'
1019 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
1024 describe('With minimum parameters', function () {
1025 it('Should upload and propagate the video', async function () {
1028 const path = '/api/v1/videos/upload'
1030 const req = request(servers[1].url)
1032 .set('Accept', 'application/json')
1033 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1034 .field('name', 'minimum parameters')
1035 .field('privacy', '1')
1036 .field('channelId', '1')
1038 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1039 .expect(HttpStatusCode.OK_200)
1041 await waitJobs(servers)
1043 for (const server of servers) {
1044 const { data } = await server.videos.list()
1045 const video = data.find(v => v.name === 'minimum parameters')
1047 const isLocal = server.url === 'http://localhost:' + servers[1].port
1048 const checkAttributes = {
1049 name: 'minimum parameters',
1058 host: 'localhost:' + servers[1].port
1062 commentsEnabled: true,
1063 downloadEnabled: true,
1065 privacy: VideoPrivacy.PUBLIC,
1067 displayName: 'Main root channel',
1068 name: 'root_channel',
1072 fixture: 'video_short.webm',
1092 await completeVideoCheck(server, video, checkAttributes)
1097 describe('TMP directory', function () {
1098 it('Should have an empty tmp directory', async function () {
1099 for (const server of servers) {
1100 await checkTmpIsEmpty(server)
1105 after(async function () {
1106 await cleanupTests(servers)