1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import * as request from 'supertest'
6 import { HttpStatusCode } from '@shared/core-utils'
8 buildAbsoluteFixturePath,
10 checkVideoFilesWereRemoved,
15 flushAndRunMultipleServers,
22 setAccessTokensToServers,
30 } from '@shared/extra-utils'
31 import { VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
33 const expect = chai.expect
35 describe('Test multiple servers', function () {
36 let servers: ServerInfo[] = []
39 let videoChannelId: number
41 before(async function () {
44 servers = await flushAndRunMultipleServers(3)
46 // Get the access tokens
47 await setAccessTokensToServers(servers)
50 const videoChannel = {
51 name: 'super_channel_name',
52 displayName: 'my channel',
53 description: 'super channel'
55 await servers[0].channelsCommand.create({ attributes: videoChannel })
56 const { data } = await servers[0].channelsCommand.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 res = await getVideosList(server.url)
71 const videos = res.body.data
72 expect(videos).to.be.an('array')
73 expect(videos.length).to.equal(0)
77 describe('Should upload the video and propagate on each server', function () {
78 it('Should upload the video on server 1 and propagate on each server', async function () {
81 const videoAttributes = {
82 name: 'my super name for server 1',
87 description: 'my super description for server 1',
88 support: 'my super support text for server 1',
89 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
90 tags: [ 'tag1p1', 'tag2p1' ],
91 channelId: videoChannelId,
92 fixture: 'video_short1.webm'
94 await uploadVideo(servers[0].url, servers[0].accessToken, videoAttributes)
96 await waitJobs(servers)
98 // All servers should have this video
99 let publishedAt: string = null
100 for (const server of servers) {
101 const isLocal = server.port === servers[0].port
102 const checkAttributes = {
103 name: 'my super name for server 1',
108 description: 'my super description for server 1',
109 support: 'my super support text for server 1',
110 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
113 host: 'localhost:' + servers[0].port
118 tags: [ 'tag1p1', 'tag2p1' ],
119 privacy: VideoPrivacy.PUBLIC,
120 commentsEnabled: true,
121 downloadEnabled: true,
123 displayName: 'my channel',
124 name: 'super_channel_name',
125 description: 'super channel',
128 fixture: 'video_short1.webm',
137 const res = await getVideosList(server.url)
138 const videos = res.body.data
139 expect(videos).to.be.an('array')
140 expect(videos.length).to.equal(1)
141 const video = videos[0]
143 await completeVideoCheck(server.url, video, checkAttributes)
144 publishedAt = video.publishedAt
148 it('Should upload the video on server 2 and propagate on each server', async function () {
153 password: 'super_password'
155 await servers[1].usersCommand.create({ username: user.username, password: user.password })
156 const userAccessToken = await servers[1].loginCommand.getAccessToken(user)
158 const videoAttributes = {
159 name: 'my super name for server 2',
164 description: 'my super description for server 2',
165 support: 'my super support text for server 2',
166 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
167 fixture: 'video_short2.webm',
168 thumbnailfile: 'thumbnail.jpg',
169 previewfile: 'preview.jpg'
171 await uploadVideo(servers[1].url, userAccessToken, videoAttributes, HttpStatusCode.OK_200, 'resumable')
174 await waitJobs(servers)
176 // All servers should have this video
177 for (const server of servers) {
178 const isLocal = server.url === 'http://localhost:' + servers[1].port
179 const checkAttributes = {
180 name: 'my super name for server 2',
185 description: 'my super description for server 2',
186 support: 'my super support text for server 2',
189 host: 'localhost:' + servers[1].port
192 commentsEnabled: true,
193 downloadEnabled: true,
195 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
196 privacy: VideoPrivacy.PUBLIC,
198 displayName: 'Main user1 channel',
199 name: 'user1_channel',
200 description: 'super channel',
203 fixture: 'video_short2.webm',
222 thumbnailfile: 'thumbnail',
223 previewfile: 'preview'
226 const res = await getVideosList(server.url)
227 const videos = res.body.data
228 expect(videos).to.be.an('array')
229 expect(videos.length).to.equal(2)
230 const video = videos[1]
232 await completeVideoCheck(server.url, video, checkAttributes)
236 it('Should upload two videos on server 3 and propagate on each server', async function () {
239 const videoAttributes1 = {
240 name: 'my super name for server 3',
245 description: 'my super description for server 3',
246 support: 'my super support text for server 3',
248 fixture: 'video_short3.webm'
250 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes1)
252 const videoAttributes2 = {
253 name: 'my super name for server 3-2',
258 description: 'my super description for server 3-2',
259 support: 'my super support text for server 3-2',
260 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
261 fixture: 'video_short.webm'
263 await uploadVideo(servers[2].url, servers[2].accessToken, videoAttributes2)
265 await waitJobs(servers)
267 // All servers should have this video
268 for (const server of servers) {
269 const isLocal = server.url === 'http://localhost:' + servers[2].port
270 const res = await getVideosList(server.url)
272 const videos = res.body.data
273 expect(videos).to.be.an('array')
274 expect(videos.length).to.equal(4)
276 // We not sure about the order of the two last uploads
279 if (videos[2].name === 'my super name for server 3') {
287 const checkAttributesVideo1 = {
288 name: 'my super name for server 3',
293 description: 'my super description for server 3',
294 support: 'my super support text for server 3',
297 host: 'localhost:' + servers[2].port
301 commentsEnabled: true,
302 downloadEnabled: true,
304 privacy: VideoPrivacy.PUBLIC,
306 displayName: 'Main root channel',
307 name: 'root_channel',
311 fixture: 'video_short3.webm',
319 await completeVideoCheck(server.url, video1, checkAttributesVideo1)
321 const checkAttributesVideo2 = {
322 name: 'my super name for server 3-2',
327 description: 'my super description for server 3-2',
328 support: 'my super support text for server 3-2',
331 host: 'localhost:' + servers[2].port
333 commentsEnabled: true,
334 downloadEnabled: true,
337 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
338 privacy: VideoPrivacy.PUBLIC,
340 displayName: 'Main root channel',
341 name: 'root_channel',
345 fixture: 'video_short.webm',
353 await completeVideoCheck(server.url, video2, checkAttributesVideo2)
358 describe('It should list local videos', function () {
359 it('Should list only local videos on server 1', async function () {
360 const { body } = await getLocalVideos(servers[0].url)
362 expect(body.total).to.equal(1)
363 expect(body.data).to.be.an('array')
364 expect(body.data.length).to.equal(1)
365 expect(body.data[0].name).to.equal('my super name for server 1')
368 it('Should list only local videos on server 2', async function () {
369 const { body } = await getLocalVideos(servers[1].url)
371 expect(body.total).to.equal(1)
372 expect(body.data).to.be.an('array')
373 expect(body.data.length).to.equal(1)
374 expect(body.data[0].name).to.equal('my super name for server 2')
377 it('Should list only local videos on server 3', async function () {
378 const { body } = await getLocalVideos(servers[2].url)
380 expect(body.total).to.equal(2)
381 expect(body.data).to.be.an('array')
382 expect(body.data.length).to.equal(2)
383 expect(body.data[0].name).to.equal('my super name for server 3')
384 expect(body.data[1].name).to.equal('my super name for server 3-2')
388 describe('Should seed the uploaded video', function () {
389 it('Should add the file 1 by asking server 3', async function () {
392 const res = await getVideosList(servers[2].url)
394 const video = res.body.data[0]
395 toRemove.push(res.body.data[2])
396 toRemove.push(res.body.data[3])
398 const res2 = await getVideo(servers[2].url, video.id)
399 const videoDetails = res2.body
401 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
402 expect(torrent.files).to.be.an('array')
403 expect(torrent.files.length).to.equal(1)
404 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
407 it('Should add the file 2 by asking server 1', async function () {
410 const res = await getVideosList(servers[0].url)
412 const video = res.body.data[1]
413 const res2 = await getVideo(servers[0].url, video.id)
414 const videoDetails = res2.body
416 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
417 expect(torrent.files).to.be.an('array')
418 expect(torrent.files.length).to.equal(1)
419 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
422 it('Should add the file 3 by asking server 2', async function () {
425 const res = await getVideosList(servers[1].url)
427 const video = res.body.data[2]
428 const res2 = await getVideo(servers[1].url, video.id)
429 const videoDetails = res2.body
431 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
432 expect(torrent.files).to.be.an('array')
433 expect(torrent.files.length).to.equal(1)
434 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
437 it('Should add the file 3-2 by asking server 1', async function () {
440 const res = await getVideosList(servers[0].url)
442 const video = res.body.data[3]
443 const res2 = await getVideo(servers[0].url, video.id)
444 const videoDetails = res2.body
446 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
447 expect(torrent.files).to.be.an('array')
448 expect(torrent.files.length).to.equal(1)
449 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
452 it('Should add the file 2 in 360p by asking server 1', async function () {
455 const res = await getVideosList(servers[0].url)
457 const video = res.body.data.find(v => v.name === 'my super name for server 2')
458 const res2 = await getVideo(servers[0].url, video.id)
459 const videoDetails = res2.body
461 const file = videoDetails.files.find(f => f.resolution.id === 360)
462 expect(file).not.to.be.undefined
464 const torrent = await webtorrentAdd(file.magnetUri)
465 expect(torrent.files).to.be.an('array')
466 expect(torrent.files.length).to.equal(1)
467 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
471 describe('Should update video views, likes and dislikes', function () {
472 let localVideosServer3 = []
473 let remoteVideosServer1 = []
474 let remoteVideosServer2 = []
475 let remoteVideosServer3 = []
477 before(async function () {
478 const res1 = await getVideosList(servers[0].url)
479 remoteVideosServer1 = res1.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
481 const res2 = await getVideosList(servers[1].url)
482 remoteVideosServer2 = res2.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
484 const res3 = await getVideosList(servers[2].url)
485 localVideosServer3 = res3.body.data.filter(video => video.isLocal === true).map(video => video.uuid)
486 remoteVideosServer3 = res3.body.data.filter(video => video.isLocal === false).map(video => video.uuid)
489 it('Should view multiple videos on owned servers', async function () {
492 await viewVideo(servers[2].url, localVideosServer3[0])
495 await viewVideo(servers[2].url, localVideosServer3[0])
496 await viewVideo(servers[2].url, localVideosServer3[1])
500 await viewVideo(servers[2].url, localVideosServer3[0])
501 await viewVideo(servers[2].url, localVideosServer3[0])
503 await waitJobs(servers)
505 // Wait the repeatable job
508 await waitJobs(servers)
510 for (const server of servers) {
511 const res = await getVideosList(server.url)
513 const videos = res.body.data
514 const video0 = videos.find(v => v.uuid === localVideosServer3[0])
515 const video1 = videos.find(v => v.uuid === localVideosServer3[1])
517 expect(video0.views).to.equal(3)
518 expect(video1.views).to.equal(1)
522 it('Should view multiple videos on each servers', async function () {
525 const tasks: Promise<any>[] = []
526 tasks.push(viewVideo(servers[0].url, remoteVideosServer1[0]))
527 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
528 tasks.push(viewVideo(servers[1].url, remoteVideosServer2[0]))
529 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[0]))
530 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
531 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
532 tasks.push(viewVideo(servers[2].url, remoteVideosServer3[1]))
533 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
534 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
535 tasks.push(viewVideo(servers[2].url, localVideosServer3[1]))
537 await Promise.all(tasks)
539 await waitJobs(servers)
541 // Wait the repeatable job
544 await waitJobs(servers)
546 let baseVideos = null
548 for (const server of servers) {
549 const res = await getVideosList(server.url)
551 const videos = res.body.data
553 // Initialize base videos for future comparisons
554 if (baseVideos === null) {
559 for (const baseVideo of baseVideos) {
560 const sameVideo = videos.find(video => video.name === baseVideo.name)
561 expect(baseVideo.views).to.equal(sameVideo.views)
566 it('Should like and dislikes videos on different services', async function () {
569 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
571 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'dislike')
573 await rateVideo(servers[0].url, servers[0].accessToken, remoteVideosServer1[0], 'like')
574 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'like')
576 await rateVideo(servers[2].url, servers[2].accessToken, localVideosServer3[1], 'dislike')
577 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[1], 'dislike')
579 await rateVideo(servers[2].url, servers[2].accessToken, remoteVideosServer3[0], 'like')
581 await waitJobs(servers)
583 await waitJobs(servers)
585 let baseVideos = null
586 for (const server of servers) {
587 const res = await getVideosList(server.url)
589 const videos = res.body.data
591 // Initialize base videos for future comparisons
592 if (baseVideos === null) {
597 for (const baseVideo of baseVideos) {
598 const sameVideo = videos.find(video => video.name === baseVideo.name)
599 expect(baseVideo.likes).to.equal(sameVideo.likes)
600 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
606 describe('Should manipulate these videos', function () {
607 it('Should update the video 3 by asking server 3', async function () {
611 name: 'my super video updated',
616 description: 'my super description updated',
617 support: 'my super support text updated',
618 tags: [ 'tag_up_1', 'tag_up_2' ],
619 thumbnailfile: 'thumbnail.jpg',
620 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
621 previewfile: 'preview.jpg'
624 await updateVideo(servers[2].url, servers[2].accessToken, toRemove[0].id, attributes)
626 await waitJobs(servers)
629 it('Should have the video 3 updated on each server', async function () {
632 for (const server of servers) {
633 const res = await getVideosList(server.url)
635 const videos = res.body.data
636 const videoUpdated = videos.find(video => video.name === 'my super video updated')
637 expect(!!videoUpdated).to.be.true
639 const isLocal = server.url === 'http://localhost:' + servers[2].port
640 const checkAttributes = {
641 name: 'my super video updated',
646 description: 'my super description updated',
647 support: 'my super support text updated',
648 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
651 host: 'localhost:' + servers[2].port
655 commentsEnabled: true,
656 downloadEnabled: true,
657 tags: [ 'tag_up_1', 'tag_up_2' ],
658 privacy: VideoPrivacy.PUBLIC,
660 displayName: 'Main root channel',
661 name: 'root_channel',
665 fixture: 'video_short3.webm',
672 thumbnailfile: 'thumbnail',
673 previewfile: 'preview'
675 await completeVideoCheck(server.url, videoUpdated, checkAttributes)
679 it('Should remove the videos 3 and 3-2 by asking server 3', async function () {
682 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[0].id)
683 await removeVideo(servers[2].url, servers[2].accessToken, toRemove[1].id)
685 await waitJobs(servers)
688 it('Should not have files of videos 3 and 3-2 on each server', async function () {
689 for (const server of servers) {
690 await checkVideoFilesWereRemoved(toRemove[0].uuid, server)
691 await checkVideoFilesWereRemoved(toRemove[1].uuid, server)
695 it('Should have videos 1 and 3 on each server', async function () {
696 for (const server of servers) {
697 const res = await getVideosList(server.url)
699 const videos = res.body.data
700 expect(videos).to.be.an('array')
701 expect(videos.length).to.equal(2)
702 expect(videos[0].name).not.to.equal(videos[1].name)
703 expect(videos[0].name).not.to.equal(toRemove[0].name)
704 expect(videos[1].name).not.to.equal(toRemove[0].name)
705 expect(videos[0].name).not.to.equal(toRemove[1].name)
706 expect(videos[1].name).not.to.equal(toRemove[1].name)
708 videoUUID = videos.find(video => video.name === 'my super name for server 1').uuid
712 it('Should get the same video by UUID on each server', async function () {
714 for (const server of servers) {
715 const res = await getVideo(server.url, videoUUID)
717 const video = res.body
719 if (baseVideo === null) {
724 expect(baseVideo.name).to.equal(video.name)
725 expect(baseVideo.uuid).to.equal(video.uuid)
726 expect(baseVideo.category.id).to.equal(video.category.id)
727 expect(baseVideo.language.id).to.equal(video.language.id)
728 expect(baseVideo.licence.id).to.equal(video.licence.id)
729 expect(baseVideo.nsfw).to.equal(video.nsfw)
730 expect(baseVideo.account.name).to.equal(video.account.name)
731 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
732 expect(baseVideo.account.url).to.equal(video.account.url)
733 expect(baseVideo.account.host).to.equal(video.account.host)
734 expect(baseVideo.tags).to.deep.equal(video.tags)
738 it('Should get the preview from each server', async function () {
739 for (const server of servers) {
740 const res = await getVideo(server.url, videoUUID)
741 const video = res.body
743 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
748 describe('Should comment these videos', function () {
749 let childOfFirstChild: VideoCommentThreadTree
751 it('Should add comment (threads and replies)', async function () {
755 const text = 'my super first comment'
756 await servers[0].commentsCommand.createThread({ videoId: videoUUID, text })
760 const text = 'my super second comment'
761 await servers[2].commentsCommand.createThread({ videoId: videoUUID, text })
764 await waitJobs(servers)
767 const threadId = await servers[1].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
769 const text = 'my super answer to thread 1'
770 await servers[1].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text })
773 await waitJobs(servers)
776 const threadId = await servers[2].commentsCommand.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
778 const body = await servers[2].commentsCommand.getThread({ videoId: videoUUID, threadId })
779 const childCommentId = body.children[0].comment.id
781 const text3 = 'my second answer to thread 1'
782 await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
784 const text2 = 'my super answer to answer of thread 1'
785 await servers[2].commentsCommand.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
788 await waitJobs(servers)
791 it('Should have these threads', async function () {
792 for (const server of servers) {
793 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
795 expect(body.total).to.equal(2)
796 expect(body.data).to.be.an('array')
797 expect(body.data).to.have.lengthOf(2)
800 const comment = body.data.find(c => c.text === 'my super first comment')
801 expect(comment).to.not.be.undefined
802 expect(comment.inReplyToCommentId).to.be.null
803 expect(comment.account.name).to.equal('root')
804 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
805 expect(comment.totalReplies).to.equal(3)
806 expect(dateIsValid(comment.createdAt as string)).to.be.true
807 expect(dateIsValid(comment.updatedAt as string)).to.be.true
811 const comment = body.data.find(c => c.text === 'my super second comment')
812 expect(comment).to.not.be.undefined
813 expect(comment.inReplyToCommentId).to.be.null
814 expect(comment.account.name).to.equal('root')
815 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
816 expect(comment.totalReplies).to.equal(0)
817 expect(dateIsValid(comment.createdAt as string)).to.be.true
818 expect(dateIsValid(comment.updatedAt as string)).to.be.true
823 it('Should have these comments', async function () {
824 for (const server of servers) {
825 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
826 const threadId = body.data.find(c => c.text === 'my super first comment').id
828 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId })
830 expect(tree.comment.text).equal('my super first comment')
831 expect(tree.comment.account.name).equal('root')
832 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
833 expect(tree.children).to.have.lengthOf(2)
835 const firstChild = tree.children[0]
836 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
837 expect(firstChild.comment.account.name).equal('root')
838 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
839 expect(firstChild.children).to.have.lengthOf(1)
841 childOfFirstChild = firstChild.children[0]
842 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
843 expect(childOfFirstChild.comment.account.name).equal('root')
844 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
845 expect(childOfFirstChild.children).to.have.lengthOf(0)
847 const secondChild = tree.children[1]
848 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
849 expect(secondChild.comment.account.name).equal('root')
850 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
851 expect(secondChild.children).to.have.lengthOf(0)
855 it('Should delete a reply', async function () {
858 await servers[2].commentsCommand.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
860 await waitJobs(servers)
863 it('Should have this comment marked as deleted', async function () {
864 for (const server of servers) {
865 const { data } = await server.commentsCommand.listThreads({ videoId: videoUUID })
866 const threadId = data.find(c => c.text === 'my super first comment').id
868 const tree = await server.commentsCommand.getThread({ videoId: videoUUID, threadId })
869 expect(tree.comment.text).equal('my super first comment')
871 const firstChild = tree.children[0]
872 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
873 expect(firstChild.children).to.have.lengthOf(1)
875 const deletedComment = firstChild.children[0].comment
876 expect(deletedComment.isDeleted).to.be.true
877 expect(deletedComment.deletedAt).to.not.be.null
878 expect(deletedComment.account).to.be.null
879 expect(deletedComment.text).to.equal('')
881 const secondChild = tree.children[1]
882 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
886 it('Should delete the thread comments', async function () {
889 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID })
890 const commentId = data.find(c => c.text === 'my super first comment').id
891 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId })
893 await waitJobs(servers)
896 it('Should have the threads marked as deleted on other servers too', async function () {
897 for (const server of servers) {
898 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
900 expect(body.total).to.equal(2)
901 expect(body.data).to.be.an('array')
902 expect(body.data).to.have.lengthOf(2)
905 const comment = body.data[0]
906 expect(comment).to.not.be.undefined
907 expect(comment.inReplyToCommentId).to.be.null
908 expect(comment.account.name).to.equal('root')
909 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
910 expect(comment.totalReplies).to.equal(0)
911 expect(dateIsValid(comment.createdAt as string)).to.be.true
912 expect(dateIsValid(comment.updatedAt as string)).to.be.true
916 const deletedComment = body.data[1]
917 expect(deletedComment).to.not.be.undefined
918 expect(deletedComment.isDeleted).to.be.true
919 expect(deletedComment.deletedAt).to.not.be.null
920 expect(deletedComment.text).to.equal('')
921 expect(deletedComment.inReplyToCommentId).to.be.null
922 expect(deletedComment.account).to.be.null
923 expect(deletedComment.totalReplies).to.equal(2)
924 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
925 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
926 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
931 it('Should delete a remote thread by the origin server', async function () {
934 const { data } = await servers[0].commentsCommand.listThreads({ videoId: videoUUID })
935 const commentId = data.find(c => c.text === 'my super second comment').id
936 await servers[0].commentsCommand.delete({ videoId: videoUUID, commentId })
938 await waitJobs(servers)
941 it('Should have the threads marked as deleted on other servers too', async function () {
942 for (const server of servers) {
943 const body = await server.commentsCommand.listThreads({ videoId: videoUUID })
945 expect(body.total).to.equal(2)
946 expect(body.data).to.have.lengthOf(2)
949 const comment = body.data[0]
950 expect(comment.text).to.equal('')
951 expect(comment.isDeleted).to.be.true
952 expect(comment.createdAt).to.not.be.null
953 expect(comment.deletedAt).to.not.be.null
954 expect(comment.account).to.be.null
955 expect(comment.totalReplies).to.equal(0)
959 const comment = body.data[1]
960 expect(comment.text).to.equal('')
961 expect(comment.isDeleted).to.be.true
962 expect(comment.createdAt).to.not.be.null
963 expect(comment.deletedAt).to.not.be.null
964 expect(comment.account).to.be.null
965 expect(comment.totalReplies).to.equal(2)
970 it('Should disable comments and download', async function () {
974 commentsEnabled: false,
975 downloadEnabled: false
978 await updateVideo(servers[0].url, servers[0].accessToken, videoUUID, attributes)
980 await waitJobs(servers)
982 for (const server of servers) {
983 const res = await getVideo(server.url, videoUUID)
984 expect(res.body.commentsEnabled).to.be.false
985 expect(res.body.downloadEnabled).to.be.false
987 const text = 'my super forbidden comment'
988 await server.commentsCommand.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
993 describe('With minimum parameters', function () {
994 it('Should upload and propagate the video', async function () {
997 const path = '/api/v1/videos/upload'
999 const req = request(servers[1].url)
1001 .set('Accept', 'application/json')
1002 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1003 .field('name', 'minimum parameters')
1004 .field('privacy', '1')
1005 .field('channelId', '1')
1007 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1008 .expect(HttpStatusCode.OK_200)
1010 await waitJobs(servers)
1012 for (const server of servers) {
1013 const res = await getVideosList(server.url)
1014 const video = res.body.data.find(v => v.name === 'minimum parameters')
1016 const isLocal = server.url === 'http://localhost:' + servers[1].port
1017 const checkAttributes = {
1018 name: 'minimum parameters',
1027 host: 'localhost:' + servers[1].port
1031 commentsEnabled: true,
1032 downloadEnabled: true,
1034 privacy: VideoPrivacy.PUBLIC,
1036 displayName: 'Main root channel',
1037 name: 'root_channel',
1041 fixture: 'video_short.webm',
1061 await completeVideoCheck(server.url, video, checkAttributes)
1066 describe('TMP directory', function () {
1067 it('Should have an empty tmp directory', async function () {
1068 for (const server of servers) {
1069 await checkTmpIsEmpty(server)
1074 after(async function () {
1075 await cleanupTests(servers)