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,
24 } from '@shared/server-commands'
26 const expect = chai.expect
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 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
50 videoChannelId = data[0].id
53 // Server 1 and server 2 follow each other
54 await doubleFollow(servers[0], servers[1])
55 // Server 1 and server 3 follow each other
56 await doubleFollow(servers[0], servers[2])
57 // Server 2 and server 3 follow each other
58 await doubleFollow(servers[1], servers[2])
61 it('Should not have videos for all servers', async function () {
62 for (const server of servers) {
63 const { data } = await server.videos.list()
64 expect(data).to.be.an('array')
65 expect(data.length).to.equal(0)
69 describe('Should upload the video and propagate on each server', function () {
70 it('Should upload the video on server 1 and propagate on each server', async function () {
74 name: 'my super name for server 1',
79 description: 'my super description for server 1',
80 support: 'my super support text for server 1',
81 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
82 tags: [ 'tag1p1', 'tag2p1' ],
83 channelId: videoChannelId,
84 fixture: 'video_short1.webm'
86 await servers[0].videos.upload({ attributes })
88 await waitJobs(servers)
90 // All servers should have this video
91 let publishedAt: string = null
92 for (const server of servers) {
93 const isLocal = server.port === servers[0].port
94 const checkAttributes = {
95 name: 'my super name for server 1',
100 description: 'my super description for server 1',
101 support: 'my super support text for server 1',
102 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
105 host: 'localhost:' + servers[0].port
110 tags: [ 'tag1p1', 'tag2p1' ],
111 privacy: VideoPrivacy.PUBLIC,
112 commentsEnabled: true,
113 downloadEnabled: true,
115 displayName: 'my channel',
116 name: 'super_channel_name',
117 description: 'super channel',
120 fixture: 'video_short1.webm',
129 const { data } = await server.videos.list()
130 expect(data).to.be.an('array')
131 expect(data.length).to.equal(1)
132 const video = data[0]
134 await completeVideoCheck(server, video, checkAttributes)
135 publishedAt = video.publishedAt as string
139 it('Should upload the video on server 2 and propagate on each server', async function () {
144 password: 'super_password'
146 await servers[1].users.create({ username: user.username, password: user.password })
147 const userAccessToken = await servers[1].login.getAccessToken(user)
150 name: 'my super name for server 2',
155 description: 'my super description for server 2',
156 support: 'my super support text for server 2',
157 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
158 fixture: 'video_short2.webm',
159 thumbnailfile: 'thumbnail.jpg',
160 previewfile: 'preview.jpg'
162 await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
165 await waitJobs(servers)
167 // All servers should have this video
168 for (const server of servers) {
169 const isLocal = server.url === 'http://localhost:' + servers[1].port
170 const checkAttributes = {
171 name: 'my super name for server 2',
176 description: 'my super description for server 2',
177 support: 'my super support text for server 2',
180 host: 'localhost:' + servers[1].port
183 commentsEnabled: true,
184 downloadEnabled: true,
186 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
187 privacy: VideoPrivacy.PUBLIC,
189 displayName: 'Main user1 channel',
190 name: 'user1_channel',
191 description: 'super channel',
194 fixture: 'video_short2.webm',
213 thumbnailfile: 'thumbnail',
214 previewfile: 'preview'
217 const { data } = await server.videos.list()
218 expect(data).to.be.an('array')
219 expect(data.length).to.equal(2)
220 const video = data[1]
222 await completeVideoCheck(server, video, checkAttributes)
226 it('Should upload two videos on server 3 and propagate on each server', async function () {
231 name: 'my super name for server 3',
236 description: 'my super description for server 3',
237 support: 'my super support text for server 3',
239 fixture: 'video_short3.webm'
241 await servers[2].videos.upload({ attributes })
246 name: 'my super name for server 3-2',
251 description: 'my super description for server 3-2',
252 support: 'my super support text for server 3-2',
253 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
254 fixture: 'video_short.webm'
256 await servers[2].videos.upload({ attributes })
259 await waitJobs(servers)
261 // All servers should have this video
262 for (const server of servers) {
263 const isLocal = server.url === 'http://localhost:' + servers[2].port
264 const { data } = await server.videos.list()
266 expect(data).to.be.an('array')
267 expect(data.length).to.equal(4)
269 // We not sure about the order of the two last uploads
272 if (data[2].name === 'my super name for server 3') {
280 const checkAttributesVideo1 = {
281 name: 'my super name for server 3',
286 description: 'my super description for server 3',
287 support: 'my super support text for server 3',
290 host: 'localhost:' + servers[2].port
294 commentsEnabled: true,
295 downloadEnabled: true,
297 privacy: VideoPrivacy.PUBLIC,
299 displayName: 'Main root channel',
300 name: 'root_channel',
304 fixture: 'video_short3.webm',
312 await completeVideoCheck(server, video1, checkAttributesVideo1)
314 const checkAttributesVideo2 = {
315 name: 'my super name for server 3-2',
320 description: 'my super description for server 3-2',
321 support: 'my super support text for server 3-2',
324 host: 'localhost:' + servers[2].port
326 commentsEnabled: true,
327 downloadEnabled: true,
330 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
331 privacy: VideoPrivacy.PUBLIC,
333 displayName: 'Main root channel',
334 name: 'root_channel',
338 fixture: 'video_short.webm',
346 await completeVideoCheck(server, video2, checkAttributesVideo2)
351 describe('It should list local videos', function () {
352 it('Should list only local videos on server 1', async function () {
353 const { data, total } = await servers[0].videos.list({ isLocal: true })
355 expect(total).to.equal(1)
356 expect(data).to.be.an('array')
357 expect(data.length).to.equal(1)
358 expect(data[0].name).to.equal('my super name for server 1')
361 it('Should list only local videos on server 2', async function () {
362 const { data, total } = await servers[1].videos.list({ isLocal: true })
364 expect(total).to.equal(1)
365 expect(data).to.be.an('array')
366 expect(data.length).to.equal(1)
367 expect(data[0].name).to.equal('my super name for server 2')
370 it('Should list only local videos on server 3', async function () {
371 const { data, total } = await servers[2].videos.list({ isLocal: true })
373 expect(total).to.equal(2)
374 expect(data).to.be.an('array')
375 expect(data.length).to.equal(2)
376 expect(data[0].name).to.equal('my super name for server 3')
377 expect(data[1].name).to.equal('my super name for server 3-2')
381 describe('Should seed the uploaded video', function () {
382 it('Should add the file 1 by asking server 3', async function () {
385 const { data } = await servers[2].videos.list()
387 const video = data[0]
388 toRemove.push(data[2])
389 toRemove.push(data[3])
391 const videoDetails = await servers[2].videos.get({ id: video.id })
392 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
393 expect(torrent.files).to.be.an('array')
394 expect(torrent.files.length).to.equal(1)
395 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
398 it('Should add the file 2 by asking server 1', async function () {
401 const { data } = await servers[0].videos.list()
403 const video = data[1]
404 const videoDetails = await servers[0].videos.get({ id: video.id })
406 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
407 expect(torrent.files).to.be.an('array')
408 expect(torrent.files.length).to.equal(1)
409 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
412 it('Should add the file 3 by asking server 2', async function () {
415 const { data } = await servers[1].videos.list()
417 const video = data[2]
418 const videoDetails = await servers[1].videos.get({ id: video.id })
420 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
421 expect(torrent.files).to.be.an('array')
422 expect(torrent.files.length).to.equal(1)
423 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
426 it('Should add the file 3-2 by asking server 1', async function () {
429 const { data } = await servers[0].videos.list()
431 const video = data[3]
432 const videoDetails = await servers[0].videos.get({ id: video.id })
434 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
435 expect(torrent.files).to.be.an('array')
436 expect(torrent.files.length).to.equal(1)
437 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
440 it('Should add the file 2 in 360p by asking server 1', async function () {
443 const { data } = await servers[0].videos.list()
445 const video = data.find(v => v.name === 'my super name for server 2')
446 const videoDetails = await servers[0].videos.get({ id: video.id })
448 const file = videoDetails.files.find(f => f.resolution.id === 360)
449 expect(file).not.to.be.undefined
451 const torrent = await webtorrentAdd(file.magnetUri)
452 expect(torrent.files).to.be.an('array')
453 expect(torrent.files.length).to.equal(1)
454 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
458 describe('Should update video views, likes and dislikes', function () {
459 let localVideosServer3 = []
460 let remoteVideosServer1 = []
461 let remoteVideosServer2 = []
462 let remoteVideosServer3 = []
464 before(async function () {
466 const { data } = await servers[0].videos.list()
467 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
471 const { data } = await servers[1].videos.list()
472 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
476 const { data } = await servers[2].videos.list()
477 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
478 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
482 it('Should view multiple videos on owned servers', async function () {
485 await servers[2].videos.view({ id: localVideosServer3[0] })
488 await servers[2].videos.view({ id: localVideosServer3[0] })
489 await servers[2].videos.view({ id: localVideosServer3[1] })
493 await servers[2].videos.view({ id: localVideosServer3[0] })
494 await servers[2].videos.view({ id: localVideosServer3[0] })
496 await waitJobs(servers)
498 // Wait the repeatable job
501 await waitJobs(servers)
503 for (const server of servers) {
504 const { data } = await server.videos.list()
506 const video0 = data.find(v => v.uuid === localVideosServer3[0])
507 const video1 = data.find(v => v.uuid === localVideosServer3[1])
509 expect(video0.views).to.equal(3)
510 expect(video1.views).to.equal(1)
514 it('Should view multiple videos on each servers', async function () {
517 const tasks: Promise<any>[] = []
518 tasks.push(servers[0].videos.view({ id: remoteVideosServer1[0] }))
519 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
520 tasks.push(servers[1].videos.view({ id: remoteVideosServer2[0] }))
521 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[0] }))
522 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
523 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
524 tasks.push(servers[2].videos.view({ id: remoteVideosServer3[1] }))
525 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
526 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
527 tasks.push(servers[2].videos.view({ id: localVideosServer3[1] }))
529 await Promise.all(tasks)
531 await waitJobs(servers)
533 // Wait the repeatable job
536 await waitJobs(servers)
538 let baseVideos = null
540 for (const server of servers) {
541 const { data } = await server.videos.list()
543 // Initialize base videos for future comparisons
544 if (baseVideos === null) {
549 for (const baseVideo of baseVideos) {
550 const sameVideo = data.find(video => video.name === baseVideo.name)
551 expect(baseVideo.views).to.equal(sameVideo.views)
556 it('Should like and dislikes videos on different services', async function () {
559 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
561 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
563 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
564 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
566 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
567 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
569 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
571 await waitJobs(servers)
573 await waitJobs(servers)
575 let baseVideos = null
576 for (const server of servers) {
577 const { data } = await server.videos.list()
579 // Initialize base videos for future comparisons
580 if (baseVideos === null) {
585 for (const baseVideo of baseVideos) {
586 const sameVideo = data.find(video => video.name === baseVideo.name)
587 expect(baseVideo.likes).to.equal(sameVideo.likes)
588 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes)
594 describe('Should manipulate these videos', function () {
595 let updatedAtMin: Date
597 it('Should update video 3', async function () {
601 name: 'my super video updated',
606 description: 'my super description updated',
607 support: 'my super support text updated',
608 tags: [ 'tag_up_1', 'tag_up_2' ],
609 thumbnailfile: 'thumbnail.jpg',
610 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
611 previewfile: 'preview.jpg'
614 updatedAtMin = new Date()
615 await servers[2].videos.update({ id: toRemove[0].id, attributes })
617 await waitJobs(servers)
620 it('Should have the video 3 updated on each server', async function () {
623 for (const server of servers) {
624 const { data } = await server.videos.list()
626 const videoUpdated = data.find(video => video.name === 'my super video updated')
627 expect(!!videoUpdated).to.be.true
629 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
631 const isLocal = server.url === 'http://localhost:' + servers[2].port
632 const checkAttributes = {
633 name: 'my super video updated',
638 description: 'my super description updated',
639 support: 'my super support text updated',
640 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
643 host: 'localhost:' + servers[2].port
647 commentsEnabled: true,
648 downloadEnabled: true,
649 tags: [ 'tag_up_1', 'tag_up_2' ],
650 privacy: VideoPrivacy.PUBLIC,
652 displayName: 'Main root channel',
653 name: 'root_channel',
657 fixture: 'video_short3.webm',
664 thumbnailfile: 'thumbnail',
665 previewfile: 'preview'
667 await completeVideoCheck(server, videoUpdated, checkAttributes)
671 it('Should only update thumbnail and update updatedAt attribute', async function () {
675 thumbnailfile: 'thumbnail.jpg'
678 updatedAtMin = new Date()
679 await servers[2].videos.update({ id: toRemove[0].id, attributes })
681 await waitJobs(servers)
683 for (const server of servers) {
684 const { data } = await server.videos.list()
686 const videoUpdated = data.find(video => video.name === 'my super video updated')
687 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
691 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
694 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
695 await saveVideoInServers(servers, id)
697 await servers[2].videos.remove({ id })
699 await waitJobs(servers)
701 for (const server of servers) {
702 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
707 it('Should have videos 1 and 3 on each server', async function () {
708 for (const server of servers) {
709 const { data } = await server.videos.list()
711 expect(data).to.be.an('array')
712 expect(data.length).to.equal(2)
713 expect(data[0].name).not.to.equal(data[1].name)
714 expect(data[0].name).not.to.equal(toRemove[0].name)
715 expect(data[1].name).not.to.equal(toRemove[0].name)
716 expect(data[0].name).not.to.equal(toRemove[1].name)
717 expect(data[1].name).not.to.equal(toRemove[1].name)
719 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
723 it('Should get the same video by UUID on each server', async function () {
725 for (const server of servers) {
726 const video = await server.videos.get({ id: videoUUID })
728 if (baseVideo === null) {
733 expect(baseVideo.name).to.equal(video.name)
734 expect(baseVideo.uuid).to.equal(video.uuid)
735 expect(baseVideo.category.id).to.equal(video.category.id)
736 expect(baseVideo.language.id).to.equal(video.language.id)
737 expect(baseVideo.licence.id).to.equal(video.licence.id)
738 expect(baseVideo.nsfw).to.equal(video.nsfw)
739 expect(baseVideo.account.name).to.equal(video.account.name)
740 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
741 expect(baseVideo.account.url).to.equal(video.account.url)
742 expect(baseVideo.account.host).to.equal(video.account.host)
743 expect(baseVideo.tags).to.deep.equal(video.tags)
747 it('Should get the preview from each server', async function () {
748 for (const server of servers) {
749 const video = await server.videos.get({ id: videoUUID })
751 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
756 describe('Should comment these videos', function () {
757 let childOfFirstChild: VideoCommentThreadTree
759 it('Should add comment (threads and replies)', async function () {
763 const text = 'my super first comment'
764 await servers[0].comments.createThread({ videoId: videoUUID, text })
768 const text = 'my super second comment'
769 await servers[2].comments.createThread({ videoId: videoUUID, text })
772 await waitJobs(servers)
775 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
777 const text = 'my super answer to thread 1'
778 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
781 await waitJobs(servers)
784 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
786 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
787 const childCommentId = body.children[0].comment.id
789 const text3 = 'my second answer to thread 1'
790 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
792 const text2 = 'my super answer to answer of thread 1'
793 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
796 await waitJobs(servers)
799 it('Should have these threads', async function () {
800 for (const server of servers) {
801 const body = await server.comments.listThreads({ videoId: videoUUID })
803 expect(body.total).to.equal(2)
804 expect(body.data).to.be.an('array')
805 expect(body.data).to.have.lengthOf(2)
808 const comment = body.data.find(c => c.text === 'my super first comment')
809 expect(comment).to.not.be.undefined
810 expect(comment.inReplyToCommentId).to.be.null
811 expect(comment.account.name).to.equal('root')
812 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
813 expect(comment.totalReplies).to.equal(3)
814 expect(dateIsValid(comment.createdAt as string)).to.be.true
815 expect(dateIsValid(comment.updatedAt as string)).to.be.true
819 const comment = body.data.find(c => c.text === 'my super second comment')
820 expect(comment).to.not.be.undefined
821 expect(comment.inReplyToCommentId).to.be.null
822 expect(comment.account.name).to.equal('root')
823 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
824 expect(comment.totalReplies).to.equal(0)
825 expect(dateIsValid(comment.createdAt as string)).to.be.true
826 expect(dateIsValid(comment.updatedAt as string)).to.be.true
831 it('Should have these comments', async function () {
832 for (const server of servers) {
833 const body = await server.comments.listThreads({ videoId: videoUUID })
834 const threadId = body.data.find(c => c.text === 'my super first comment').id
836 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
838 expect(tree.comment.text).equal('my super first comment')
839 expect(tree.comment.account.name).equal('root')
840 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
841 expect(tree.children).to.have.lengthOf(2)
843 const firstChild = tree.children[0]
844 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
845 expect(firstChild.comment.account.name).equal('root')
846 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
847 expect(firstChild.children).to.have.lengthOf(1)
849 childOfFirstChild = firstChild.children[0]
850 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
851 expect(childOfFirstChild.comment.account.name).equal('root')
852 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
853 expect(childOfFirstChild.children).to.have.lengthOf(0)
855 const secondChild = tree.children[1]
856 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
857 expect(secondChild.comment.account.name).equal('root')
858 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
859 expect(secondChild.children).to.have.lengthOf(0)
863 it('Should delete a reply', async function () {
866 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
868 await waitJobs(servers)
871 it('Should have this comment marked as deleted', async function () {
872 for (const server of servers) {
873 const { data } = await server.comments.listThreads({ videoId: videoUUID })
874 const threadId = data.find(c => c.text === 'my super first comment').id
876 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
877 expect(tree.comment.text).equal('my super first comment')
879 const firstChild = tree.children[0]
880 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
881 expect(firstChild.children).to.have.lengthOf(1)
883 const deletedComment = firstChild.children[0].comment
884 expect(deletedComment.isDeleted).to.be.true
885 expect(deletedComment.deletedAt).to.not.be.null
886 expect(deletedComment.account).to.be.null
887 expect(deletedComment.text).to.equal('')
889 const secondChild = tree.children[1]
890 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
894 it('Should delete the thread comments', async function () {
897 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
898 const commentId = data.find(c => c.text === 'my super first comment').id
899 await servers[0].comments.delete({ videoId: videoUUID, commentId })
901 await waitJobs(servers)
904 it('Should have the threads marked as deleted on other servers too', async function () {
905 for (const server of servers) {
906 const body = await server.comments.listThreads({ videoId: videoUUID })
908 expect(body.total).to.equal(2)
909 expect(body.data).to.be.an('array')
910 expect(body.data).to.have.lengthOf(2)
913 const comment = body.data[0]
914 expect(comment).to.not.be.undefined
915 expect(comment.inReplyToCommentId).to.be.null
916 expect(comment.account.name).to.equal('root')
917 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
918 expect(comment.totalReplies).to.equal(0)
919 expect(dateIsValid(comment.createdAt as string)).to.be.true
920 expect(dateIsValid(comment.updatedAt as string)).to.be.true
924 const deletedComment = body.data[1]
925 expect(deletedComment).to.not.be.undefined
926 expect(deletedComment.isDeleted).to.be.true
927 expect(deletedComment.deletedAt).to.not.be.null
928 expect(deletedComment.text).to.equal('')
929 expect(deletedComment.inReplyToCommentId).to.be.null
930 expect(deletedComment.account).to.be.null
931 expect(deletedComment.totalReplies).to.equal(2)
932 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
933 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
934 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
939 it('Should delete a remote thread by the origin server', async function () {
942 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
943 const commentId = data.find(c => c.text === 'my super second comment').id
944 await servers[0].comments.delete({ videoId: videoUUID, commentId })
946 await waitJobs(servers)
949 it('Should have the threads marked as deleted on other servers too', async function () {
950 for (const server of servers) {
951 const body = await server.comments.listThreads({ videoId: videoUUID })
953 expect(body.total).to.equal(2)
954 expect(body.data).to.have.lengthOf(2)
957 const comment = body.data[0]
958 expect(comment.text).to.equal('')
959 expect(comment.isDeleted).to.be.true
960 expect(comment.createdAt).to.not.be.null
961 expect(comment.deletedAt).to.not.be.null
962 expect(comment.account).to.be.null
963 expect(comment.totalReplies).to.equal(0)
967 const comment = body.data[1]
968 expect(comment.text).to.equal('')
969 expect(comment.isDeleted).to.be.true
970 expect(comment.createdAt).to.not.be.null
971 expect(comment.deletedAt).to.not.be.null
972 expect(comment.account).to.be.null
973 expect(comment.totalReplies).to.equal(2)
978 it('Should disable comments and download', async function () {
982 commentsEnabled: false,
983 downloadEnabled: false
986 await servers[0].videos.update({ id: videoUUID, attributes })
988 await waitJobs(servers)
990 for (const server of servers) {
991 const video = await server.videos.get({ id: videoUUID })
992 expect(video.commentsEnabled).to.be.false
993 expect(video.downloadEnabled).to.be.false
995 const text = 'my super forbidden comment'
996 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
1001 describe('With minimum parameters', function () {
1002 it('Should upload and propagate the video', async function () {
1005 const path = '/api/v1/videos/upload'
1007 const req = request(servers[1].url)
1009 .set('Accept', 'application/json')
1010 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1011 .field('name', 'minimum parameters')
1012 .field('privacy', '1')
1013 .field('channelId', '1')
1015 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1016 .expect(HttpStatusCode.OK_200)
1018 await waitJobs(servers)
1020 for (const server of servers) {
1021 const { data } = await server.videos.list()
1022 const video = data.find(v => v.name === 'minimum parameters')
1024 const isLocal = server.url === 'http://localhost:' + servers[1].port
1025 const checkAttributes = {
1026 name: 'minimum parameters',
1035 host: 'localhost:' + servers[1].port
1039 commentsEnabled: true,
1040 downloadEnabled: true,
1042 privacy: VideoPrivacy.PUBLIC,
1044 displayName: 'Main root channel',
1045 name: 'root_channel',
1049 fixture: 'video_short.webm',
1069 await completeVideoCheck(server, video, checkAttributes)
1074 describe('TMP directory', function () {
1075 it('Should have an empty tmp directory', async function () {
1076 for (const server of servers) {
1077 await checkTmpIsEmpty(server)
1082 after(async function () {
1083 await cleanupTests(servers)