aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/multiple-servers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/api/multiple-servers.ts')
-rw-r--r--server/tests/api/multiple-servers.ts135
1 files changed, 115 insertions, 20 deletions
diff --git a/server/tests/api/multiple-servers.ts b/server/tests/api/multiple-servers.ts
index 6fe1fb651..06274d4cc 100644
--- a/server/tests/api/multiple-servers.ts
+++ b/server/tests/api/multiple-servers.ts
@@ -1,32 +1,18 @@
1/* tslint:disable:no-unused-expression */ 1/* tslint:disable:no-unused-expression */
2 2
3import 'mocha'
4import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha'
5import { join } from 'path' 5import { join } from 'path'
6import * as request from 'supertest' 6import * as request from 'supertest'
7import { VideoComment, VideoCommentThreadTree } from '../../../shared/models/videos/video-comment.model'
7 8
8import { 9import {
9 dateIsValid, 10 addVideoChannel, dateIsValid, doubleFollow, flushAndRunMultipleServers, flushTests, getUserAccessToken, getVideo,
10 flushAndRunMultipleServers, 11 getVideoChannelsList, getVideosList, killallServers, rateVideo, removeVideo, ServerInfo, setAccessTokensToServers, testVideoImage,
11 flushTests, 12 updateVideo, uploadVideo, wait, webtorrentAdd
12 getVideo,
13 getVideosList,
14 killallServers,
15 rateVideo,
16 removeVideo,
17 ServerInfo,
18 setAccessTokensToServers,
19 testVideoImage,
20 updateVideo,
21 uploadVideo,
22 wait,
23 webtorrentAdd,
24 addVideoChannel,
25 getVideoChannelsList,
26 getUserAccessToken,
27 doubleFollow
28} from '../utils' 13} from '../utils'
29import { createUser } from '../utils/users' 14import { createUser } from '../utils/users'
15import { addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, getVideoThreadComments } from '../utils/video-comments'
30import { viewVideo } from '../utils/videos' 16import { viewVideo } from '../utils/videos'
31 17
32const expect = chai.expect 18const expect = chai.expect
@@ -709,6 +695,115 @@ describe('Test multiple servers', function () {
709 }) 695 })
710 }) 696 })
711 697
698 describe('Should comment these videos', function () {
699 it('Should add comment (threads and replies)', async function () {
700 this.timeout(25000)
701
702 {
703 const text = 'my super first comment'
704 await addVideoCommentThread(servers[ 0 ].url, servers[ 0 ].accessToken, videoUUID, text)
705 }
706
707 {
708 const text = 'my super second comment'
709 await addVideoCommentThread(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, text)
710 }
711
712 await wait(5000)
713
714 {
715 const res = await getVideoCommentThreads(servers[1].url, videoUUID, 0, 5)
716 const threadId = res.body.data.find(c => c.text === 'my super first comment').id
717
718 const text = 'my super answer to thread 1'
719 await addVideoCommentReply(servers[ 1 ].url, servers[ 1 ].accessToken, videoUUID, threadId, text)
720 }
721
722 await wait(5000)
723
724 {
725 const res1 = await getVideoCommentThreads(servers[2].url, videoUUID, 0, 5)
726 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
727
728 const res2 = await getVideoThreadComments(servers[2].url, videoUUID, threadId)
729 const childCommentId = res2.body.children[0].comment.id
730
731 const text3 = 'my second answer to thread 1'
732 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, threadId, text3)
733
734 const text2 = 'my super answer to answer of thread 1'
735 await addVideoCommentReply(servers[ 2 ].url, servers[ 2 ].accessToken, videoUUID, childCommentId, text2)
736 }
737
738 await wait(5000)
739 })
740
741 it('Should have these threads', async function () {
742 for (const server of servers) {
743 const res = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
744
745 expect(res.body.total).to.equal(2)
746 expect(res.body.data).to.be.an('array')
747 expect(res.body.data).to.have.lengthOf(2)
748
749 {
750 const comment: VideoComment = res.body.data.find(c => c.text === 'my super first comment')
751 expect(comment).to.not.be.undefined
752 expect(comment.inReplyToCommentId).to.be.null
753 expect(comment.account.name).to.equal('root')
754 expect(comment.account.host).to.equal('localhost:9001')
755 expect(comment.totalReplies).to.equal(3)
756 expect(dateIsValid(comment.createdAt as string)).to.be.true
757 expect(dateIsValid(comment.updatedAt as string)).to.be.true
758 }
759
760 {
761 const comment: VideoComment = res.body.data.find(c => c.text === 'my super second comment')
762 expect(comment).to.not.be.undefined
763 expect(comment.inReplyToCommentId).to.be.null
764 expect(comment.account.name).to.equal('root')
765 expect(comment.account.host).to.equal('localhost:9003')
766 expect(comment.totalReplies).to.equal(0)
767 expect(dateIsValid(comment.createdAt as string)).to.be.true
768 expect(dateIsValid(comment.updatedAt as string)).to.be.true
769 }
770 }
771 })
772
773 it('Should have these comments', async function () {
774 for (const server of servers) {
775 const res1 = await getVideoCommentThreads(server.url, videoUUID, 0, 5)
776 const threadId = res1.body.data.find(c => c.text === 'my super first comment').id
777
778 const res2 = await getVideoThreadComments(server.url, videoUUID, threadId)
779
780 const tree: VideoCommentThreadTree = res2.body
781 expect(tree.comment.text).equal('my super first comment')
782 expect(tree.comment.account.name).equal('root')
783 expect(tree.comment.account.host).equal('localhost:9001')
784 expect(tree.children).to.have.lengthOf(2)
785
786 const firstChild = tree.children[0]
787 expect(firstChild.comment.text).to.equal('my super answer to thread 1')
788 expect(firstChild.comment.account.name).equal('root')
789 expect(firstChild.comment.account.host).equal('localhost:9002')
790 expect(firstChild.children).to.have.lengthOf(1)
791
792 const childOfFirstChild = firstChild.children[0]
793 expect(childOfFirstChild.comment.text).to.equal('my super answer to answer of thread 1')
794 expect(childOfFirstChild.comment.account.name).equal('root')
795 expect(childOfFirstChild.comment.account.host).equal('localhost:9003')
796 expect(childOfFirstChild.children).to.have.lengthOf(0)
797
798 const secondChild = tree.children[1]
799 expect(secondChild.comment.text).to.equal('my second answer to thread 1')
800 expect(secondChild.comment.account.name).equal('root')
801 expect(secondChild.comment.account.host).equal('localhost:9003')
802 expect(secondChild.children).to.have.lengthOf(0)
803 }
804 })
805 })
806
712 describe('With minimum parameters', function () { 807 describe('With minimum parameters', function () {
713 it('Should upload and propagate the video', async function () { 808 it('Should upload and propagate the video', async function () {
714 this.timeout(50000) 809 this.timeout(50000)