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,
22 setAccessTokensToServers,
23 setDefaultAccountAvatar,
24 setDefaultChannelAvatar,
27 } from '@shared/server-commands'
29 const expect = chai.expect
31 describe('Test multiple servers', function () {
32 let servers: PeerTubeServer[] = []
35 let videoChannelId: number
37 before(async function () {
40 servers = await createMultipleServers(3)
42 // Get the access tokens
43 await setAccessTokensToServers(servers)
46 const videoChannel = {
47 name: 'super_channel_name',
48 displayName: 'my channel',
49 description: 'super channel'
51 await servers[0].channels.create({ attributes: videoChannel })
52 await setDefaultChannelAvatar(servers[0], videoChannel.name)
53 await setDefaultAccountAvatar(servers)
55 const { data } = await servers[0].channels.list({ start: 0, count: 1 })
56 videoChannelId = data[0].id
59 // Server 1 and server 2 follow each other
60 await doubleFollow(servers[0], servers[1])
61 // Server 1 and server 3 follow each other
62 await doubleFollow(servers[0], servers[2])
63 // Server 2 and server 3 follow each other
64 await doubleFollow(servers[1], servers[2])
67 it('Should not have videos for all servers', async function () {
68 for (const server of servers) {
69 const { data } = await server.videos.list()
70 expect(data).to.be.an('array')
71 expect(data.length).to.equal(0)
75 describe('Should upload the video and propagate on each server', function () {
76 it('Should upload the video on server 1 and propagate on each server', async function () {
80 name: 'my super name for server 1',
85 description: 'my super description for server 1',
86 support: 'my super support text for server 1',
87 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
88 tags: [ 'tag1p1', 'tag2p1' ],
89 channelId: videoChannelId,
90 fixture: 'video_short1.webm'
92 await servers[0].videos.upload({ attributes })
94 await waitJobs(servers)
96 // All servers should have this video
97 let publishedAt: string = null
98 for (const server of servers) {
99 const isLocal = server.port === servers[0].port
100 const checkAttributes = {
101 name: 'my super name for server 1',
106 description: 'my super description for server 1',
107 support: 'my super support text for server 1',
108 originallyPublishedAt: '2019-02-10T13:38:14.449Z',
111 host: 'localhost:' + servers[0].port
116 tags: [ 'tag1p1', 'tag2p1' ],
117 privacy: VideoPrivacy.PUBLIC,
118 commentsEnabled: true,
119 downloadEnabled: true,
121 displayName: 'my channel',
122 name: 'super_channel_name',
123 description: 'super channel',
126 fixture: 'video_short1.webm',
135 const { data } = await server.videos.list()
136 expect(data).to.be.an('array')
137 expect(data.length).to.equal(1)
138 const video = data[0]
140 await completeVideoCheck(server, video, checkAttributes)
141 publishedAt = video.publishedAt as string
143 expect(video.channel.avatars).to.have.lengthOf(2)
144 expect(video.account.avatars).to.have.lengthOf(2)
146 for (const image of [ ...video.channel.avatars, ...video.account.avatars ]) {
147 expect(image.createdAt).to.exist
148 expect(image.updatedAt).to.exist
149 expect(image.width).to.be.above(20).and.below(1000)
150 expect(image.path).to.exist
152 await makeGetRequest({
155 expectedStatus: HttpStatusCode.OK_200
161 it('Should upload the video on server 2 and propagate on each server', async function () {
166 password: 'super_password'
168 await servers[1].users.create({ username: user.username, password: user.password })
169 const userAccessToken = await servers[1].login.getAccessToken(user)
172 name: 'my super name for server 2',
177 description: 'my super description for server 2',
178 support: 'my super support text for server 2',
179 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
180 fixture: 'video_short2.webm',
181 thumbnailfile: 'thumbnail.jpg',
182 previewfile: 'preview.jpg'
184 await servers[1].videos.upload({ token: userAccessToken, attributes, mode: 'resumable' })
187 await waitJobs(servers)
189 // All servers should have this video
190 for (const server of servers) {
191 const isLocal = server.url === 'http://localhost:' + servers[1].port
192 const checkAttributes = {
193 name: 'my super name for server 2',
198 description: 'my super description for server 2',
199 support: 'my super support text for server 2',
202 host: 'localhost:' + servers[1].port
205 commentsEnabled: true,
206 downloadEnabled: true,
208 tags: [ 'tag1p2', 'tag2p2', 'tag3p2' ],
209 privacy: VideoPrivacy.PUBLIC,
211 displayName: 'Main user1 channel',
212 name: 'user1_channel',
213 description: 'super channel',
216 fixture: 'video_short2.webm',
235 thumbnailfile: 'thumbnail',
236 previewfile: 'preview'
239 const { data } = await server.videos.list()
240 expect(data).to.be.an('array')
241 expect(data.length).to.equal(2)
242 const video = data[1]
244 await completeVideoCheck(server, video, checkAttributes)
248 it('Should upload two videos on server 3 and propagate on each server', async function () {
253 name: 'my super name for server 3',
258 description: 'my super description for server 3',
259 support: 'my super support text for server 3',
261 fixture: 'video_short3.webm'
263 await servers[2].videos.upload({ attributes })
268 name: 'my super name for server 3-2',
273 description: 'my super description for server 3-2',
274 support: 'my super support text for server 3-2',
275 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
276 fixture: 'video_short.webm'
278 await servers[2].videos.upload({ attributes })
281 await waitJobs(servers)
283 // All servers should have this video
284 for (const server of servers) {
285 const isLocal = server.url === 'http://localhost:' + servers[2].port
286 const { data } = await server.videos.list()
288 expect(data).to.be.an('array')
289 expect(data.length).to.equal(4)
291 // We not sure about the order of the two last uploads
294 if (data[2].name === 'my super name for server 3') {
302 const checkAttributesVideo1 = {
303 name: 'my super name for server 3',
308 description: 'my super description for server 3',
309 support: 'my super support text for server 3',
312 host: 'localhost:' + servers[2].port
316 commentsEnabled: true,
317 downloadEnabled: true,
319 privacy: VideoPrivacy.PUBLIC,
321 displayName: 'Main root channel',
322 name: 'root_channel',
326 fixture: 'video_short3.webm',
334 await completeVideoCheck(server, video1, checkAttributesVideo1)
336 const checkAttributesVideo2 = {
337 name: 'my super name for server 3-2',
342 description: 'my super description for server 3-2',
343 support: 'my super support text for server 3-2',
346 host: 'localhost:' + servers[2].port
348 commentsEnabled: true,
349 downloadEnabled: true,
352 tags: [ 'tag2p3', 'tag3p3', 'tag4p3' ],
353 privacy: VideoPrivacy.PUBLIC,
355 displayName: 'Main root channel',
356 name: 'root_channel',
360 fixture: 'video_short.webm',
368 await completeVideoCheck(server, video2, checkAttributesVideo2)
373 describe('It should list local videos', function () {
374 it('Should list only local videos on server 1', async function () {
375 const { data, total } = await servers[0].videos.list({ isLocal: true })
377 expect(total).to.equal(1)
378 expect(data).to.be.an('array')
379 expect(data.length).to.equal(1)
380 expect(data[0].name).to.equal('my super name for server 1')
383 it('Should list only local videos on server 2', async function () {
384 const { data, total } = await servers[1].videos.list({ isLocal: true })
386 expect(total).to.equal(1)
387 expect(data).to.be.an('array')
388 expect(data.length).to.equal(1)
389 expect(data[0].name).to.equal('my super name for server 2')
392 it('Should list only local videos on server 3', async function () {
393 const { data, total } = await servers[2].videos.list({ isLocal: true })
395 expect(total).to.equal(2)
396 expect(data).to.be.an('array')
397 expect(data.length).to.equal(2)
398 expect(data[0].name).to.equal('my super name for server 3')
399 expect(data[1].name).to.equal('my super name for server 3-2')
403 describe('Should seed the uploaded video', function () {
404 it('Should add the file 1 by asking server 3', async function () {
407 const { data } = await servers[2].videos.list()
409 const video = data[0]
410 toRemove.push(data[2])
411 toRemove.push(data[3])
413 const videoDetails = await servers[2].videos.get({ id: video.id })
414 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
415 expect(torrent.files).to.be.an('array')
416 expect(torrent.files.length).to.equal(1)
417 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
420 it('Should add the file 2 by asking server 1', async function () {
423 const { data } = await servers[0].videos.list()
425 const video = data[1]
426 const videoDetails = await servers[0].videos.get({ id: video.id })
428 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
429 expect(torrent.files).to.be.an('array')
430 expect(torrent.files.length).to.equal(1)
431 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
434 it('Should add the file 3 by asking server 2', async function () {
437 const { data } = await servers[1].videos.list()
439 const video = data[2]
440 const videoDetails = await servers[1].videos.get({ id: video.id })
442 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri, true)
443 expect(torrent.files).to.be.an('array')
444 expect(torrent.files.length).to.equal(1)
445 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
448 it('Should add the file 3-2 by asking server 1', async function () {
451 const { data } = await servers[0].videos.list()
453 const video = data[3]
454 const videoDetails = await servers[0].videos.get({ id: video.id })
456 const torrent = await webtorrentAdd(videoDetails.files[0].magnetUri)
457 expect(torrent.files).to.be.an('array')
458 expect(torrent.files.length).to.equal(1)
459 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
462 it('Should add the file 2 in 360p by asking server 1', async function () {
465 const { data } = await servers[0].videos.list()
467 const video = data.find(v => v.name === 'my super name for server 2')
468 const videoDetails = await servers[0].videos.get({ id: video.id })
470 const file = videoDetails.files.find(f => f.resolution.id === 360)
471 expect(file).not.to.be.undefined
473 const torrent = await webtorrentAdd(file.magnetUri)
474 expect(torrent.files).to.be.an('array')
475 expect(torrent.files.length).to.equal(1)
476 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
480 describe('Should update video views, likes and dislikes', function () {
481 let localVideosServer3 = []
482 let remoteVideosServer1 = []
483 let remoteVideosServer2 = []
484 let remoteVideosServer3 = []
486 before(async function () {
488 const { data } = await servers[0].videos.list()
489 remoteVideosServer1 = data.filter(video => video.isLocal === false).map(video => video.uuid)
493 const { data } = await servers[1].videos.list()
494 remoteVideosServer2 = data.filter(video => video.isLocal === false).map(video => video.uuid)
498 const { data } = await servers[2].videos.list()
499 localVideosServer3 = data.filter(video => video.isLocal === true).map(video => video.uuid)
500 remoteVideosServer3 = data.filter(video => video.isLocal === false).map(video => video.uuid)
504 it('Should view multiple videos on owned servers', async function () {
507 await servers[2].views.simulateView({ id: localVideosServer3[0] })
510 await servers[2].views.simulateView({ id: localVideosServer3[0] })
511 await servers[2].views.simulateView({ id: localVideosServer3[1] })
515 await servers[2].views.simulateView({ id: localVideosServer3[0] })
516 await servers[2].views.simulateView({ id: localVideosServer3[0] })
518 await waitJobs(servers)
520 for (const server of servers) {
521 await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } })
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].views.simulateView({ id: remoteVideosServer1[0] }))
542 tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] }))
543 tasks.push(servers[1].views.simulateView({ id: remoteVideosServer2[0] }))
544 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[0] }))
545 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
546 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
547 tasks.push(servers[2].views.simulateView({ id: remoteVideosServer3[1] }))
548 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
549 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
550 tasks.push(servers[2].views.simulateView({ id: localVideosServer3[1] }))
552 await Promise.all(tasks)
554 await waitJobs(servers)
556 for (const server of servers) {
557 await server.debug.sendCommand({ body: { command: 'process-video-views-buffer' } })
560 await waitJobs(servers)
562 let baseVideos = null
564 for (const server of servers) {
565 const { data } = await server.videos.list()
567 // Initialize base videos for future comparisons
568 if (baseVideos === null) {
573 for (const baseVideo of baseVideos) {
574 const sameVideo = data.find(video => video.name === baseVideo.name)
575 expect(baseVideo.views).to.equal(sameVideo.views)
580 it('Should like and dislikes videos on different services', async function () {
583 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
585 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'dislike' })
587 await servers[0].videos.rate({ id: remoteVideosServer1[0], rating: 'like' })
588 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'like' })
590 await servers[2].videos.rate({ id: localVideosServer3[1], rating: 'dislike' })
591 await servers[2].videos.rate({ id: remoteVideosServer3[1], rating: 'dislike' })
593 await servers[2].videos.rate({ id: remoteVideosServer3[0], rating: 'like' })
595 await waitJobs(servers)
597 await waitJobs(servers)
599 let baseVideos = null
600 for (const server of servers) {
601 const { data } = await server.videos.list()
603 // Initialize base videos for future comparisons
604 if (baseVideos === null) {
609 for (const baseVideo of baseVideos) {
610 const sameVideo = data.find(video => video.name === baseVideo.name)
611 expect(baseVideo.likes).to.equal(sameVideo.likes, `Likes of ${sameVideo.uuid} do not correspond`)
612 expect(baseVideo.dislikes).to.equal(sameVideo.dislikes, `Dislikes of ${sameVideo.uuid} do not correspond`)
618 describe('Should manipulate these videos', function () {
619 let updatedAtMin: Date
621 it('Should update video 3', async function () {
625 name: 'my super video updated',
630 description: 'my super description updated',
631 support: 'my super support text updated',
632 tags: [ 'tag_up_1', 'tag_up_2' ],
633 thumbnailfile: 'thumbnail.jpg',
634 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
635 previewfile: 'preview.jpg'
638 updatedAtMin = new Date()
639 await servers[2].videos.update({ id: toRemove[0].id, attributes })
641 await waitJobs(servers)
644 it('Should have the video 3 updated on each server', async function () {
647 for (const server of servers) {
648 const { data } = await server.videos.list()
650 const videoUpdated = data.find(video => video.name === 'my super video updated')
651 expect(!!videoUpdated).to.be.true
653 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
655 const isLocal = server.url === 'http://localhost:' + servers[2].port
656 const checkAttributes = {
657 name: 'my super video updated',
662 description: 'my super description updated',
663 support: 'my super support text updated',
664 originallyPublishedAt: '2019-02-11T13:38:14.449Z',
667 host: 'localhost:' + servers[2].port
671 commentsEnabled: true,
672 downloadEnabled: true,
673 tags: [ 'tag_up_1', 'tag_up_2' ],
674 privacy: VideoPrivacy.PUBLIC,
676 displayName: 'Main root channel',
677 name: 'root_channel',
681 fixture: 'video_short3.webm',
688 thumbnailfile: 'thumbnail',
689 previewfile: 'preview'
691 await completeVideoCheck(server, videoUpdated, checkAttributes)
695 it('Should only update thumbnail and update updatedAt attribute', async function () {
699 thumbnailfile: 'thumbnail.jpg'
702 updatedAtMin = new Date()
703 await servers[2].videos.update({ id: toRemove[0].id, attributes })
705 await waitJobs(servers)
707 for (const server of servers) {
708 const { data } = await server.videos.list()
710 const videoUpdated = data.find(video => video.name === 'my super video updated')
711 expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
715 it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
718 for (const id of [ toRemove[0].id, toRemove[1].id ]) {
719 await saveVideoInServers(servers, id)
721 await servers[2].videos.remove({ id })
723 await waitJobs(servers)
725 for (const server of servers) {
726 await checkVideoFilesWereRemoved({ server, video: server.store.videoDetails })
731 it('Should have videos 1 and 3 on each server', async function () {
732 for (const server of servers) {
733 const { data } = await server.videos.list()
735 expect(data).to.be.an('array')
736 expect(data.length).to.equal(2)
737 expect(data[0].name).not.to.equal(data[1].name)
738 expect(data[0].name).not.to.equal(toRemove[0].name)
739 expect(data[1].name).not.to.equal(toRemove[0].name)
740 expect(data[0].name).not.to.equal(toRemove[1].name)
741 expect(data[1].name).not.to.equal(toRemove[1].name)
743 videoUUID = data.find(video => video.name === 'my super name for server 1').uuid
747 it('Should get the same video by UUID on each server', async function () {
749 for (const server of servers) {
750 const video = await server.videos.get({ id: videoUUID })
752 if (baseVideo === null) {
757 expect(baseVideo.name).to.equal(video.name)
758 expect(baseVideo.uuid).to.equal(video.uuid)
759 expect(baseVideo.category.id).to.equal(video.category.id)
760 expect(baseVideo.language.id).to.equal(video.language.id)
761 expect(baseVideo.licence.id).to.equal(video.licence.id)
762 expect(baseVideo.nsfw).to.equal(video.nsfw)
763 expect(baseVideo.account.name).to.equal(video.account.name)
764 expect(baseVideo.account.displayName).to.equal(video.account.displayName)
765 expect(baseVideo.account.url).to.equal(video.account.url)
766 expect(baseVideo.account.host).to.equal(video.account.host)
767 expect(baseVideo.tags).to.deep.equal(video.tags)
771 it('Should get the preview from each server', async function () {
772 for (const server of servers) {
773 const video = await server.videos.get({ id: videoUUID })
775 await testImage(server.url, 'video_short1-preview.webm', video.previewPath)
780 describe('Should comment these videos', function () {
781 let childOfFirstChild: VideoCommentThreadTree
783 it('Should add comment (threads and replies)', async function () {
787 const text = 'my super first comment'
788 await servers[0].comments.createThread({ videoId: videoUUID, text })
792 const text = 'my super second comment'
793 await servers[2].comments.createThread({ videoId: videoUUID, text })
796 await waitJobs(servers)
799 const threadId = await servers[1].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
801 const text = 'my super answer to thread 1'
802 await servers[1].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text })
805 await waitJobs(servers)
808 const threadId = await servers[2].comments.findCommentId({ videoId: videoUUID, text: 'my super first comment' })
810 const body = await servers[2].comments.getThread({ videoId: videoUUID, threadId })
811 const childCommentId = body.children[0].comment.id
813 const text3 = 'my second answer to thread 1'
814 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: threadId, text: text3 })
816 const text2 = 'my super answer to answer of thread 1'
817 await servers[2].comments.addReply({ videoId: videoUUID, toCommentId: childCommentId, text: text2 })
820 await waitJobs(servers)
823 it('Should have these threads', async function () {
824 for (const server of servers) {
825 const body = await server.comments.listThreads({ videoId: videoUUID })
827 expect(body.total).to.equal(2)
828 expect(body.data).to.be.an('array')
829 expect(body.data).to.have.lengthOf(2)
832 const comment = body.data.find(c => c.text === 'my super first comment')
833 expect(comment).to.not.be.undefined
834 expect(comment.inReplyToCommentId).to.be.null
835 expect(comment.account.name).to.equal('root')
836 expect(comment.account.host).to.equal('localhost:' + servers[0].port)
837 expect(comment.totalReplies).to.equal(3)
838 expect(dateIsValid(comment.createdAt as string)).to.be.true
839 expect(dateIsValid(comment.updatedAt as string)).to.be.true
843 const comment = body.data.find(c => c.text === 'my super second comment')
844 expect(comment).to.not.be.undefined
845 expect(comment.inReplyToCommentId).to.be.null
846 expect(comment.account.name).to.equal('root')
847 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
848 expect(comment.totalReplies).to.equal(0)
849 expect(dateIsValid(comment.createdAt as string)).to.be.true
850 expect(dateIsValid(comment.updatedAt as string)).to.be.true
855 it('Should have these comments', async function () {
856 for (const server of servers) {
857 const body = await server.comments.listThreads({ videoId: videoUUID })
858 const threadId = body.data.find(c => c.text === 'my super first comment').id
860 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
862 expect(tree.comment.text).equal('my super first comment')
863 expect(tree.comment.account.name).equal('root')
864 expect(tree.comment.account.host).equal('localhost:' + servers[0].port)
865 expect(tree.children).to.have.lengthOf(2)
867 const firstChild = tree.children[0]
868 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
869 expect(firstChild.comment.account.name).equal('root')
870 expect(firstChild.comment.account.host).equal('localhost:' + servers[1].port)
871 expect(firstChild.children).to.have.lengthOf(1)
873 childOfFirstChild = firstChild.children[0]
874 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
875 expect(childOfFirstChild.comment.account.name).equal('root')
876 expect(childOfFirstChild.comment.account.host).equal('localhost:' + servers[2].port)
877 expect(childOfFirstChild.children).to.have.lengthOf(0)
879 const secondChild = tree.children[1]
880 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
881 expect(secondChild.comment.account.name).equal('root')
882 expect(secondChild.comment.account.host).equal('localhost:' + servers[2].port)
883 expect(secondChild.children).to.have.lengthOf(0)
887 it('Should delete a reply', async function () {
890 await servers[2].comments.delete({ videoId: videoUUID, commentId: childOfFirstChild.comment.id })
892 await waitJobs(servers)
895 it('Should have this comment marked as deleted', async function () {
896 for (const server of servers) {
897 const { data } = await server.comments.listThreads({ videoId: videoUUID })
898 const threadId = data.find(c => c.text === 'my super first comment').id
900 const tree = await server.comments.getThread({ videoId: videoUUID, threadId })
901 expect(tree.comment.text).equal('my super first comment')
903 const firstChild = tree.children[0]
904 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
905 expect(firstChild.children).to.have.lengthOf(1)
907 const deletedComment = firstChild.children[0].comment
908 expect(deletedComment.isDeleted).to.be.true
909 expect(deletedComment.deletedAt).to.not.be.null
910 expect(deletedComment.account).to.be.null
911 expect(deletedComment.text).to.equal('')
913 const secondChild = tree.children[1]
914 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
918 it('Should delete the thread comments', async function () {
921 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
922 const commentId = data.find(c => c.text === 'my super first comment').id
923 await servers[0].comments.delete({ videoId: videoUUID, commentId })
925 await waitJobs(servers)
928 it('Should have the threads marked as deleted on other servers too', async function () {
929 for (const server of servers) {
930 const body = await server.comments.listThreads({ videoId: videoUUID })
932 expect(body.total).to.equal(2)
933 expect(body.data).to.be.an('array')
934 expect(body.data).to.have.lengthOf(2)
937 const comment = body.data[0]
938 expect(comment).to.not.be.undefined
939 expect(comment.inReplyToCommentId).to.be.null
940 expect(comment.account.name).to.equal('root')
941 expect(comment.account.host).to.equal('localhost:' + servers[2].port)
942 expect(comment.totalReplies).to.equal(0)
943 expect(dateIsValid(comment.createdAt as string)).to.be.true
944 expect(dateIsValid(comment.updatedAt as string)).to.be.true
948 const deletedComment = body.data[1]
949 expect(deletedComment).to.not.be.undefined
950 expect(deletedComment.isDeleted).to.be.true
951 expect(deletedComment.deletedAt).to.not.be.null
952 expect(deletedComment.text).to.equal('')
953 expect(deletedComment.inReplyToCommentId).to.be.null
954 expect(deletedComment.account).to.be.null
955 expect(deletedComment.totalReplies).to.equal(2)
956 expect(dateIsValid(deletedComment.createdAt as string)).to.be.true
957 expect(dateIsValid(deletedComment.updatedAt as string)).to.be.true
958 expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
963 it('Should delete a remote thread by the origin server', async function () {
966 const { data } = await servers[0].comments.listThreads({ videoId: videoUUID })
967 const commentId = data.find(c => c.text === 'my super second comment').id
968 await servers[0].comments.delete({ videoId: videoUUID, commentId })
970 await waitJobs(servers)
973 it('Should have the threads marked as deleted on other servers too', async function () {
974 for (const server of servers) {
975 const body = await server.comments.listThreads({ videoId: videoUUID })
977 expect(body.total).to.equal(2)
978 expect(body.data).to.have.lengthOf(2)
981 const comment = body.data[0]
982 expect(comment.text).to.equal('')
983 expect(comment.isDeleted).to.be.true
984 expect(comment.createdAt).to.not.be.null
985 expect(comment.deletedAt).to.not.be.null
986 expect(comment.account).to.be.null
987 expect(comment.totalReplies).to.equal(0)
991 const comment = body.data[1]
992 expect(comment.text).to.equal('')
993 expect(comment.isDeleted).to.be.true
994 expect(comment.createdAt).to.not.be.null
995 expect(comment.deletedAt).to.not.be.null
996 expect(comment.account).to.be.null
997 expect(comment.totalReplies).to.equal(2)
1002 it('Should disable comments and download', async function () {
1005 const attributes = {
1006 commentsEnabled: false,
1007 downloadEnabled: false
1010 await servers[0].videos.update({ id: videoUUID, attributes })
1012 await waitJobs(servers)
1014 for (const server of servers) {
1015 const video = await server.videos.get({ id: videoUUID })
1016 expect(video.commentsEnabled).to.be.false
1017 expect(video.downloadEnabled).to.be.false
1019 const text = 'my super forbidden comment'
1020 await server.comments.createThread({ videoId: videoUUID, text, expectedStatus: HttpStatusCode.CONFLICT_409 })
1025 describe('With minimum parameters', function () {
1026 it('Should upload and propagate the video', async function () {
1029 const path = '/api/v1/videos/upload'
1031 const req = request(servers[1].url)
1033 .set('Accept', 'application/json')
1034 .set('Authorization', 'Bearer ' + servers[1].accessToken)
1035 .field('name', 'minimum parameters')
1036 .field('privacy', '1')
1037 .field('channelId', '1')
1039 await req.attach('videofile', buildAbsoluteFixturePath('video_short.webm'))
1040 .expect(HttpStatusCode.OK_200)
1042 await waitJobs(servers)
1044 for (const server of servers) {
1045 const { data } = await server.videos.list()
1046 const video = data.find(v => v.name === 'minimum parameters')
1048 const isLocal = server.url === 'http://localhost:' + servers[1].port
1049 const checkAttributes = {
1050 name: 'minimum parameters',
1059 host: 'localhost:' + servers[1].port
1063 commentsEnabled: true,
1064 downloadEnabled: true,
1066 privacy: VideoPrivacy.PUBLIC,
1068 displayName: 'Main root channel',
1069 name: 'root_channel',
1073 fixture: 'video_short.webm',
1093 await completeVideoCheck(server, video, checkAttributes)
1098 describe('TMP directory', function () {
1099 it('Should have an empty tmp directory', async function () {
1100 for (const server of servers) {
1101 await checkTmpIsEmpty(server)
1106 after(async function () {
1107 await cleanupTests(servers)