1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
3 import { expect } from 'chai'
4 import request from 'supertest'
7 checkVideoFilesWereRemoved,
12 } from '@server/tests/shared'
13 import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
14 import { HttpStatusCode, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
17 createMultipleServers,
21 setAccessTokensToServers,
22 setDefaultAccountAvatar,
23 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, video, 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, video, 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, video1, 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, video2, 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 })
411 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
412 expect(torrent.files).to.be.an('array')
413 expect(torrent.files.length).to.equal(1)
414 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
417 it('Should add the file 2 by asking server 1', async function () {
420 const { data } = await servers[0].videos.list()
422 const video = data[1]
423 const videoDetails = await servers[0].videos.get({ id: video.id })
425 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
426 expect(torrent.files).to.be.an('array')
427 expect(torrent.files.length).to.equal(1)
428 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
431 it('Should add the file 3 by asking server 2', async function () {
434 const { data } = await servers[1].videos.list()
436 const video = data[2]
437 const videoDetails = await servers[1].videos.get({ id: video.id })
439 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
440 expect(torrent.files).to.be.an('array')
441 expect(torrent.files.length).to.equal(1)
442 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
445 it('Should add the file 3-2 by asking server 1', async function () {
448 const { data } = await servers[0].videos.list()
450 const video = data[3]
451 const videoDetails = await servers[0].videos.get({ id: video.id })
453 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
454 expect(torrent.files).to.be.an('array')
455 expect(torrent.files.length).to.equal(1)
456 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
459 it('Should add the file 2 in 360p by asking server 1', async function () {
462 const { data } = await servers[0].videos.list()
464 const video = data.find(v => v.name === 'my super name for server 2')
465 const videoDetails = await servers[0].videos.get({ id: video.id })
467 const file = videoDetails.files.find(f => f.resolution.id === 360)
468 expect(file).not.to.be.undefined
470 const torrent = await webtorrentAdd(file.magnetUri)
471 expect(torrent.files).to.be.an('array')
472 expect(torrent.files.length).to.equal(1)
473 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
477 describe('Should update video views, likes and dislikes', function () {
478 let localVideosServer3 = []
479 let remoteVideosServer1 = []
480 let remoteVideosServer2 = []
481 let remoteVideosServer3 = []
483 before(async function () {
485 const { data } = await servers[0].videos.list()
486 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
490 const { data } = await servers[1].videos.list()
491 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
495 const { data } = await servers[2].videos.list()
496 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
497 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
501 it('Should view multiple videos on owned servers', async function () {
504 await servers[2].views.simulateView({ id: localVideosServer3[0] })
507 await servers[2].views.simulateView({ id: localVideosServer3[0] })
508 await servers[2].views.simulateView({ id: localVideosServer3[1] })
512 await servers[2].views.simulateView({ id: localVideosServer3[0] })
513 await servers[2].views.simulateView({ id: localVideosServer3[0] })
515 await waitJobs(servers)
517 for (const server of servers) {
518 await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } })
521 await waitJobs(servers)
523 for (const server of servers) {
524 const { data } = await server.videos.list()
526 const video0 = data.find(v => v.uuid === localVideosServer3[0])
527 const video1 = data.find(v => v.uuid === localVideosServer3[1])
529 expect(video0.views).to.equal(3)
530 expect(video1.views).to.equal(1)
534 it('Should view multiple videos on each servers', async function () {
537 const tasks: Promise<any>[] = []
538 tasks.push(servers[0].views.simulateView({ id: remoteVideosServer1[0] }))
539 tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] }))
540 tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] }))
541 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[0] }))
542 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
543 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
544 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
545 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
546 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
547 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
549 await Promise.all(tasks)
551 await waitJobs(servers)
553 for (const server of servers) {
554 await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } })
557 await waitJobs(servers)
559 let baseVideos = null
561 for (const server of servers) {
562 const { data } = await server.videos.list()
564 // Initialize base videos for future comparisons
565 if (baseVideos === null) {
570 for (const baseVideo of baseVideos) {
571 const sameVideo = data.find(video => video.name === baseVideo.name)
572 expect(baseVideo.views).to.equal(sameVideo.views)
577 it('Should like and dislikes videos on different services', async function () {
580 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
582 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
584 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
585 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
587 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
588 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
590 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
592 await waitJobs(servers)
594 await waitJobs(servers)
596 let baseVideos = null
597 for (const server of servers) {
598 const { data } = await server.videos.list()
600 // Initialize base videos for future comparisons
601 if (baseVideos === null) {
606 for (const baseVideo of baseVideos) {
607 const sameVideo = data.find(video => video.name === baseVideo.name)
608 expect(baseVideo.likes).to.equal(sameVideo.likes, `Likes of ${sameVideo.uuid} do not correspond`)
609 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes, `Dislikes of ${sameVideo.uuid} do not correspond`)
615 describe('Should manipulate these videos', function () {
616 let updatedAtMin: Date
618 it('Should update video 3', async function () {
622 name: 'my super video updated',
627 description: 'my super description updated',
628 support: 'my super support text updated',
629 tags: [ 'tag_up_1', 'tag_up_2' ],
630 thumbnailfile: 'thumbnail.jpg',
631 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
632 previewfile: 'preview.jpg'
635 updatedAtMin = new Date()
636 await servers[2].videos.update({ id: toRemove[0].id, attributes })
638 await waitJobs(servers)
641 it('Should have the video 3 updated on each server', async function () {
644 for (const server of servers) {
645 const { data } = await server.videos.list()
647 const videoUpdated = data.find(video => video.name === 'my super video updated')
648 expect(!!videoUpdated).to.be.true
650 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
652 const isLocal = server.url === servers[2].url
653 const checkAttributes = {
654 name: 'my super video updated',
659 description: 'my super description updated',
660 support: 'my super support text updated',
661 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
664 host: servers[2].host
668 commentsEnabled: true,
669 downloadEnabled: true,
670 tags: [ 'tag_up_1', 'tag_up_2' ],
671 privacy: VideoPrivacy.PUBLIC,
673 displayName: 'Main root channel',
674 name: 'root_channel',
678 fixture: 'video_short3.webm',
685 thumbnailfile: 'thumbnail',
686 previewfile: 'preview'
688 await completeVideoCheck(server, videoUpdated, checkAttributes)
692 it('Should only update thumbnail and update updatedAt attribute', async function () {
696 thumbnailfile: 'thumbnail.jpg'
699 updatedAtMin = new Date()
700 await servers[2].videos.update({ id: toRemove[0].id, attributes })
702 await waitJobs(servers)
704 for (const server of servers) {
705 const { data } = await server.videos.list()
707 const videoUpdated = data.find(video => video.name === 'my super video updated')
708 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
712 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
715 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
716 await saveVideoInServers(servers, id)
718 await servers[2].videos.remove({ id })
720 await waitJobs(servers)
722 for (const server of servers) {
723 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
728 it('Should have videos 1 and 3 on each server', async function () {
729 for (const server of servers) {
730 const { data } = await server.videos.list()
732 expect(data).to.be.an('array')
733 expect(data.length).to.equal(2)
734 expect(data[0].name).not.to.equal(data[1].name)
735 expect(data[0].name).not.to.equal(toRemove[0].name)
736 expect(data[1].name).not.to.equal(toRemove[0].name)
737 expect(data[0].name).not.to.equal(toRemove[1].name)
738 expect(data[1].name).not.to.equal(toRemove[1].name)
740 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
744 it('Should get the same video by UUID on each server', async function () {
746 for (const server of servers) {
747 const video = await server.videos.get({ id: videoUUID })
749 if (baseVideo === null) {
754 expect(baseVideo.name).to.equal(video.name)
755 expect(baseVideo.uuid).to.equal(video.uuid)
756 expect(baseVideo.category.id).to.equal(video.category.id)
757 expect(baseVideo.language.id).to.equal(video.language.id)
758 expect(baseVideo.licence.id).to.equal(video.licence.id)
759 expect(baseVideo.nsfw).to.equal(video.nsfw)
760 expect(baseVideo.account.name).to.equal(video.account.name)
761 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
762 expect(baseVideo.account.url).to.equal(video.account.url)
763 expect(baseVideo.account.host).to.equal(video.account.host)
764 expect(baseVideo.tags).to.deep.equal(video.tags)
768 it('Should get the preview from each server', async function () {
769 for (const server of servers) {
770 const video = await server.videos.get({ id: videoUUID })
772 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
777 describe('Should comment these videos', function () {
778 let childOfFirstChild: VideoCommentThreadTree
780 it('Should add comment (threads and replies)', async function () {
784 const text = 'my super first comment'
785 await servers[0].comments.createThread({ videoId: videoUUID, text })
789 const text = 'my super second comment'
790 await servers[2].comments.createThread({ videoId: videoUUID, text })
793 await waitJobs(servers)
796 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
798 const text = 'my super answer to thread 1'
799 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
802 await waitJobs(servers)
805 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
807 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
808 const childCommentId = body.children[0].comment.id
810 const text3 = 'my second answer to thread 1'
811 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
813 const text2 = 'my super answer to answer of thread 1'
814 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
817 await waitJobs(servers)
820 it('Should have these threads', async function () {
821 for (const server of servers) {
822 const body = await server.comments.listThreads({ videoId: videoUUID })
824 expect(body.total).to.equal(2)
825 expect(body.data).to.be.an('array')
826 expect(body.data).to.have.lengthOf(2)
829 const comment = body.data.find(c => c.text === 'my super first comment')
830 expect(comment).to.not.be.undefined
831 expect(comment.inReplyToCommentId).to.be.null
832 expect(comment.account.name).to.equal('root')
833 expect(comment.account.host).to.equal(servers[0].host)
834 expect(comment.totalReplies).to.equal(3)
835 expect(dateIsValid(comment.createdAt as string)).to.be.true
836 expect(dateIsValid(comment.updatedAt as string)).to.be.true
840 const comment = body.data.find(c => c.text === 'my super second comment')
841 expect(comment).to.not.be.undefined
842 expect(comment.inReplyToCommentId).to.be.null
843 expect(comment.account.name).to.equal('root')
844 expect(comment.account.host).to.equal(servers[2].host)
845 expect(comment.totalReplies).to.equal(0)
846 expect(dateIsValid(comment.createdAt as string)).to.be.true
847 expect(dateIsValid(comment.updatedAt as string)).to.be.true
852 it('Should have these comments', async function () {
853 for (const server of servers) {
854 const body = await server.comments.listThreads({ videoId: videoUUID })
855 const threadId = body.data.find(c => c.text === 'my super first comment').id
857 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
859 expect(tree.comment.text).equal('my super first comment')
860 expect(tree.comment.account.name).equal('root')
861 expect(tree.comment.account.host).equal(servers[0].host)
862 expect(tree.children).to.have.lengthOf(2)
864 const firstChild = tree.children[0]
865 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
866 expect(firstChild.comment.account.name).equal('root')
867 expect(firstChild.comment.account.host).equal(servers[1].host)
868 expect(firstChild.children).to.have.lengthOf(1)
870 childOfFirstChild = firstChild.children[0]
871 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
872 expect(childOfFirstChild.comment.account.name).equal('root')
873 expect(childOfFirstChild.comment.account.host).equal(servers[2].host)
874 expect(childOfFirstChild.children).to.have.lengthOf(0)
876 const secondChild = tree.children[1]
877 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
878 expect(secondChild.comment.account.name).equal('root')
879 expect(secondChild.comment.account.host).equal(servers[2].host)
880 expect(secondChild.children).to.have.lengthOf(0)
884 it('Should delete a reply', async function () {
887 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
889 await waitJobs(servers)
892 it('Should have this comment marked as deleted', async function () {
893 for (const server of servers) {
894 const { data } = await server.comments.listThreads({ videoId: videoUUID })
895 const threadId = data.find(c => c.text === 'my super first comment').id
897 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
898 expect(tree.comment.text).equal('my super first comment')
900 const firstChild = tree.children[0]
901 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
902 expect(firstChild.children).to.have.lengthOf(1)
904 const deletedComment = firstChild.children[0].comment
905 expect(deletedComment.isDeleted).to.be.true
906 expect(deletedComment.deletedAt).to.not.be.null
907 expect(deletedComment.account).to.be.null
908 expect(deletedComment.text).to.equal('')
910 const secondChild = tree.children[1]
911 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
915 it('Should delete the thread comments', async function () {
918 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
919 const commentId = data.find(c => c.text === 'my super first comment').id
920 await servers[0].comments.delete({ videoId: videoUUID, commentId })
922 await waitJobs(servers)
925 it('Should have the threads marked as deleted on other servers too', async function () {
926 for (const server of servers) {
927 const body = await server.comments.listThreads({ videoId: videoUUID })
929 expect(body.total).to.equal(2)
930 expect(body.data).to.be.an('array')
931 expect(body.data).to.have.lengthOf(2)
934 const comment = body.data[0]
935 expect(comment).to.not.be.undefined
936 expect(comment.inReplyToCommentId).to.be.null
937 expect(comment.account.name).to.equal('root')
938 expect(comment.account.host).to.equal(servers[2].host)
939 expect(comment.totalReplies).to.equal(0)
940 expect(dateIsValid(comment.createdAt as string)).to.be.true
941 expect(dateIsValid(comment.updatedAt as string)).to.be.true
945 const deletedComment = body.data[1]
946 expect(deletedComment).to.not.be.undefined
947 expect(deletedComment.isDeleted).to.be.true
948 expect(deletedComment.deletedAt).to.not.be.null
949 expect(deletedComment.text).to.equal('')
950 expect(deletedComment.inReplyToCommentId).to.be.null
951 expect(deletedComment.account).to.be.null
952 expect(deletedComment.totalReplies).to.equal(2)
953 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
954 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
955 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
960 it('Should delete a remote thread by the origin server', async function () {
963 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
964 const commentId = data.find(c => c.text === 'my super second comment').id
965 await servers[0].comments.delete({ videoId: videoUUID, commentId })
967 await waitJobs(servers)
970 it('Should have the threads marked as deleted on other servers too', async function () {
971 for (const server of servers) {
972 const body = await server.comments.listThreads({ videoId: videoUUID })
974 expect(body.total).to.equal(2)
975 expect(body.data).to.have.lengthOf(2)
978 const comment = body.data[0]
979 expect(comment.text).to.equal('')
980 expect(comment.isDeleted).to.be.true
981 expect(comment.createdAt).to.not.be.null
982 expect(comment.deletedAt).to.not.be.null
983 expect(comment.account).to.be.null
984 expect(comment.totalReplies).to.equal(0)
988 const comment = body.data[1]
989 expect(comment.text).to.equal('')
990 expect(comment.isDeleted).to.be.true
991 expect(comment.createdAt).to.not.be.null
992 expect(comment.deletedAt).to.not.be.null
993 expect(comment.account).to.be.null
994 expect(comment.totalReplies).to.equal(2)
999 it('Should disable comments and download', async function () {
1002 const attributes = {
1003 commentsEnabled: false,
1004 downloadEnabled: false
1007 await servers[0].videos.update({ id: videoUUID, attributes })
1009 await waitJobs(servers)
1011 for (const server of servers) {
1012 const video = await server.videos.get({ id: videoUUID })
1013 expect(video.commentsEnabled).to.be.false
1014 expect(video.downloadEnabled).to.be.false
1016 const text = 'my super forbidden comment'
1017 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
1022 describe('With minimum parameters', function () {
1023 it('Should upload and propagate the video', async function () {
1024 this.timeout(120000)
1026 const path = '/api/v1/videos/upload'
1028 const req = request(servers[1].url)
1030 .set('Accept', 'application/json')
1031 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1032 .field('name', 'minimum parameters')
1033 .field('privacy', '1')
1034 .field('channelId', '1')
1036 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1037 .expect(HttpStatusCode.OK_200)
1039 await waitJobs(servers)
1041 for (const server of servers) {
1042 const { data } = await server.videos.list()
1043 const video = data.find(v => v.name === 'minimum parameters')
1045 const isLocal = server.url === servers[1].url
1046 const checkAttributes = {
1047 name: 'minimum parameters',
1056 host: servers[1].host
1060 commentsEnabled: true,
1061 downloadEnabled: true,
1063 privacy: VideoPrivacy.PUBLIC,
1065 displayName: 'Main root channel',
1066 name: 'root_channel',
1070 fixture: 'video_short.webm',
1090 await completeVideoCheck(server, video, checkAttributes)
1095 describe('TMP directory', function () {
1096 it('Should have an empty tmp directory', async function () {
1097 for (const server of servers) {
1098 await checkTmpIsEmpty(server)
1103 after(async function () {
1104 await cleanupTests(servers)